On Saturday 08 February 2003 09:43pm, Jeremy Hill wrote:
> Greetings,
>
> For those who still use ROM's note system, I have a question for you. 
> After I make a new_note(), fill the fields, and append_note(pnote), should
> I then:
>
> 1. free_note(pnote)
> 2. pnote = NULL;
> 3. Nothing.
>
> Personally, I would think #1, but code I have been looking at seems to
> favor pnote = NULL.  Seems like this would cause memory to leak.
>
> Any suggestions?
>
> - Jeremy Hill

The append_note() function does not allocate new memory for the note.  It 
simply determines the correct note list and inserts the pointer, then writes 
the new note to disk. This is why you simply set pnote NULL, since if you 
free_note()'d it, the pointer in the note list would now point to invalid 
data.

-- 
Bobby Bailey    | "The only source of knowledge is experience."
MUD Developer   | -- Albert Einstein
Internet Junkie | PGP Keys: http://chil.kyndig.com/pgp
http://www.kyndig.com/ -- Mud & Online Text Game Community


Reply via email to