delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/21/02:50:58

Message-ID: <F02EDE79D030D11192BA006008136ED11A61CD@pamela.x3m.se>
From: Ztream <Ztream AT x3m DOT se>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: RE: ? strange problem
Date: Mon, 21 Dec 1998 08:47:02 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2232.9)
Reply-To: djgpp AT delorie DOT com

> -----Original Message-----
> From:	Rosemary Sheppard [SMTP:rosi AT ulster DOT net]
> Sent:	Monday, December 21, 1998 4:43 AM
> To:	djgpp AT delorie DOT com
> Subject:	Re: ? strange problem
> 
> > 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
> >
<code removed>

I cut-n-pasted the example code, added the necessary header files and added
the following main function:

int main( void )
    {
    Heap heap;
    Heap_Construct((char *) &heap, 100, 0);
    }

The program works wonderfully, printing "heap->size = 0" and exiting.

My guess would be that the problem lies in the function calling
Heap_Contruct or even earlier, causing the first argument (the pointer to
char) to contain garbage. A write to this address could probably be
responsible for the abnormal behaviour of the function.
Of course, the possibility exists that I am just lucky and you aren't ;).

Btw, just out of curiosity, why is the first pointer declared as char * and
not Heap *? :)

Regards
 / Z

---------------------------------------------------------------------------
Ztream / 1x4x9 - "The white dwarf"
ztream AT x3m DOT se \ www.highrad.x3m.se/Ztream
Free your mind.

- Raw text -


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