home *** CD-ROM | disk | FTP | other *** search
- Path: doc.ic.ac.uk!not-for-mail
- From: mdf@doc.ic.ac.uk (Martin Frost)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: More linked list nonsense
- Date: 26 Jan 1996 15:29:59 -0000
- Organization: Dept. of Computing, Imperial College, University of London, UK.
- Distribution: world
- Message-ID: <4eas1n$46h@oak22.doc.ic.ac.uk>
- References: <4e5nih$iib@news.sdd.hp.com>
- Reply-To: mdf@doc.ic.ac.uk (Martin Frost)
- NNTP-Posting-Host: oak22.doc.ic.ac.uk
- X-Newsreader: mxrn 6.18-23
-
-
- In article <4e5nih$iib@news.sdd.hp.com>, Jeff Grimmett <jgrimm@sdd.hp.com> writes:
- >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. :-)
-
- Remove() is a low-level list manipulation function. To see what it does, look
- at the macro REMOVE in the assembly file "exec/lists.i".
-
- It frees no memory, does no list arbitration, and makes no assumptions about
- anything other than that the first 8 bytes of the specified node are a
- MinimalListNode structure (ie pointer to next, pointer to previous). Since
- standard ListNodes simply have additional data tacked on the end, this works
- for all such nodes. You are responsible for freeing any memory associated with
- the node (or indeed you may not want to, for example if the node is embedded
- as preinitialised data in your program's code).
-
- I don't know if the exec.library function returns a pointer to the node or
- not: I don't have the Autodocs with me right now. Even if it doesn't, it isn't
- really *too* much effort to cache the node pointer in a variable while calling
- the function :-)
-
- Martin
-