Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!emory!mephisto!mcnc!rti!sas!walker From: walker@sas.UUCP (Doug Walker) Newsgroups: comp.sys.amiga Subject: Re: Dynamic Memory Allocation Message-ID: <1569@sas.UUCP> Date: 15 Feb 90 22:46:26 GMT References: <2061540@mtsg.ubc.ca> Reply-To: walker@sas.UUCP (Doug Walker) Organization: SAS Institute Inc, Cary NC Lines: 27 In article <2061540@mtsg.ubc.ca> Kim_Sletten@MTSG.UBC.CA writes: > > >I am using Lattice C 5.2 function calloc() to dynamically allocate >memory as needed. And free() when no longer needed. These functions >seem to work as documented ie. free() does return a 0. However, >the free'd memory does not show up as being available until the >program terminates. Am I missing something? The UNIX free() function is required to work in the following situation: for(s=head; s != NULL; s=s->next) free(s); This means that free() is required to 'hold on' to the most recently freed memory chunk until the next call to free(), or until the program exits. I suggest using AllocMem and remembering the length, or using AllocRemember. Either of these system-supplied memory allocators will work find and will not link in all the code required to do malloc() and free() from lc.lib. ***** =*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)471-6436 = *|. o.| || | o |// "I try to make everyone's day a little more surreal." ====== - Calvin (to Hobbes) usenet: ...mcnc!rti!sas!walker plink: dwalker bix: djwalker