Path: chuka.playstation.co.uk!news From: James Russell Newsgroups: scee.yaroze.beginners Subject: Re: A 'c' question... Date: Thu, 25 Feb 1999 08:36:38 +0000 Organization: Sony Computer Entertainment Europe Lines: 28 Message-ID: <36D50B96.8E621C69@scee.sony.co.uk> References: <7b27fm$9po14@chuka.playstation.co.uk> NNTP-Posting-Host: mailgate.scee.sony.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5 [en] (Win95; I) X-Accept-Language: en Johan MacLeod wrote: > > I have been working hard to get my first game out there and am nearly > there! I do have a problem, though. I am using a linked list in the game and > am not sure how to free the space back to the system. I think I need the > 'free' function. Do I need to 'free' each pointer in the linked list, > individually, or can I just 'free' the head of the list (or would that just > leave a chunk of used up memory with no access to it)? Depends how you've allocated your memory. If you've allocated each element using malloc(), then you'll have to free() each element as well. Just use 'free' with the address you got back from malloc(). _However_, as I recall there is a bug in free which basically means it doesn't work. :O( Instead, you could figure out the maximum number of structures you'd need, allocate a big chunk of space for them, and do it all manually. This might work out to be a bit more time efficient, depending on your implementation. You'd have to manage the used/free areas yourself. Cheers, James -- == James_Russell@scee.sony.co.uk +44 (171) 447-1626 == Developer Support Engineer - Sony Computer Entertainment Europe Amnesia: You've read the book now read the book.