home *** CD-ROM | disk | FTP | other *** search
- Path: sable.ox.ac.uk!sjoh0358
- From: sjoh0358@sable.ox.ac.uk (Ian Parkinson)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: More linked list nonsense
- Date: 25 Jan 1996 16:50:39 GMT
- Organization: Oxford University, England
- Message-ID: <4e8ccv$7ei@news.ox.ac.uk>
- References: <4e5nih$iib@news.sdd.hp.com>
- NNTP-Posting-Host: sable.ox.ac.uk
-
- In article <4e5nih$iib@news.sdd.hp.com>,
- Jeff Grimmett <jgrimm@sdd.hp.com> wrote:
- >
- >Howdy,
- >
- >It just occurred to me last night, as I pored over steaming code, that
- >the function Remove() (used to remove nodes from linked lists) might
- >POSSIBLY not be freeing the memory allocated to the node it is removing.
- >Does anyone have some insight on this? It's difficult to deallocate a
- >node once it's not part of the list, but it's pretty STUPID to free it
- >BEFORE. :-)
-
- I don't have the docs handy, and I haven't done anything with linked lists
- for a while, but as far as I recall:
-
- Remove() simply fixes the pointers on adjacent nodes to effectively push the
- chosen node out of the list. It still remains in memory and so has to be freed
- explicitly by the program. At least, that's the way I did it!
-
- In general, if you explicitly allocate the memory with a MemAlloc() or
- whatever, then it is also up to you to deallocate it. This goes for any part of
- the OS, not just linked lists.
-
- To deallocate after Remove(), just store the address of the node somewhere
- before you Remove() it. Then deallocate using this address.
-
- Ian
-
-
-