delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/20/22:45:08

From: Rosemary Sheppard <rosi AT ulster DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: ? strange problem
Date: Sun, 20 Dec 1998 22:43:26 -0500
Organization: none
Lines: 65
Message-ID: <367DC3DE.D0C4EF8E@ulster.net>
References: <36663692 DOT 410E88AA AT cs DOT ccu DOT edu DOT tw>
NNTP-Posting-Host: 208.133.194.54
Mime-Version: 1.0
X-Trace: 914211622 TEBWCEYUUC236D085C usenet77.supernews.com
X-Complaints-To: newsabuse AT remarQ DOT com
X-Mailer: Mozilla 4.04 [en] (Win95; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I had the same problem... i'm guessing it's just a bug that can't be fixed,
but i got around it by finding where the variable got screwed up and
assigning it to another variable of the same type just before that point,
and used that variable instead... this seems to fix the bug

lmc83 wrote:

> Hi
>
>        Could any one tell me what happend with the following code, why I
> assign
>       "heap->size = 0", but result is not "heap->size = 0".
>        Is it bug of djgpp?
>                                              Thanks for your help
>
>                                                                    Liang
> Ming-Chung
>
> ----------------------------------------------------------------
> typedef struct
> {
>     int max_size;                       /* max heap size */
>     int size;                           /* current heap size */
>     void **element;
>     int (*cmp)(void *t1, void *t2);
> }Heap;
>
> int Heap_Construct(char *ptr, int s, int (*cmp)(void *t1, void *t2))
> {
>     Heap *heap;
>     int used_size = 0;
>     char buffer[20];
>
>     heap = (Heap *)ptr;
>     ptr += sizeof(Heap);
>     used_size += sizeof(Heap);
>     heap->max_size = s;
>     heap->size = 0;
>     if (heap->size<0)
>     {
>        cputs("strange\r\n");
>     }
>     cputs("heap->size=");
>     cputs(itoa(heap->size, buffer, 10));
>     cputs("\r\n");
>     heap->element = (void **)ptr;
>     heap->cmp = cmp;
>     used_size += sizeof(void *)*s;
>
>     return used_size;
> }
>
> ========== result ================
> strange
> heap->size = -1
>
> ==========makefile===============
> CC=gcc
> INCS=-I/rtos/include
> CFLAGS= $(INCS) -DDEBUG
> heap.o: heap.c heap.h
>     $(CC) -c heap.c $(CFLAGS)



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019