Mail Archives: djgpp/1998/12/20/22:45:08
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 -