home *** CD-ROM | disk | FTP | other *** search
- Path: wiedmann.neckar-alb.de!jochen
- From: jochen@neckar-alb.de (Jochen Wiedmann)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Must I free my linked lists? (GCC)
- Date: 23 Jan 1996 13:12:29 GMT
- Organization: ISS Internet Service Stuttgart GmbH
- Message-ID: <4e2mrt$bc6@iss1.neckar-alb.de>
- References: <4dudic$aif@vixen.cso.uiuc.edu>
- Reply-To: wiedmann@neckar-alb.de
- NNTP-Posting-Host: wiedmann.neckar-alb.de
- X-Newsreader: TIN [version 1.2 PL2]
-
- Unknown (Dannyman@uiuc.edu) wrote:
- : I'm writing a program that makes use of dynamic memory allocation through
- : linked lists using malloc() ... from an implementation PoV there's no need
- : to flush this stuff as after the queue is created it's output and the
- : program exits. My question is;
-
- : "When my program exits, is the dynamic memory in the queues returned to
- : the system or is a "memory hole" left, so that I should actually go back and
- : return all the memory in my program ..."
-
- You can be sure, if
-
- 1.) You are using a version of malloc(), that isn't broken.
- The malloc() coming with your C compiler can be assumed
- to work fine.
- 2.) Your program exits in the correct way by calling exit()
- or returning from main().
- 3.) You are *sure*, that there are no other functions obtaining
- memory from the system. Examples:
-
- OpenWindow()
- AllocDosObject()
- Open()
-
- These are all using AllocMem, AllocPooled or something similar.
- The memory obtained by them is released using the respective
- counterpart: CloseWindow(), FreeDosObject() or Close(). The
- atexit() function is a good choice, if you want to be sure,
- that these are being called.
-
-
- Bye,
-
- Jochen
-