Yes, what you've described is a classic memory leak.
Normally you have to loop through the linked list, freeing each element.
while (ch->structure_here != NULL)
{
STRUCTURE_HERE *tmp = ch->structure_here;
ch->structure_here = ch->structure_here->next;
free(tmp);
}
Or something algorithmically similar...
--Palrich.
On Tue, 2004-06-15 at 15:50, [EMAIL PROTECTED] wrote:
> I have a few new structures that I have created. This would be my first time
> adding them to the CHAR and PC_DATA structures.
>
> In these structures I have a linked list. When I remove one of them I just set
> it to NULL, such as:
>
> ch->structure_here = NULL;
>
> I am not sure if this is enough, as the structure contains 5 or 6 fields of
> data. I suspect that the data is still there, but the pointer doesn't point to
> it. This then would increase memory over time.
> So, you have to free it first with a function, such as:
> free_structure_here(ch->structure_here);
> then set it to NULL.
>
> ch->structure_here = NULL;
>
> Is this correct? Or does just setting the pointer to NULL do enough?
>
> When I add to the linked list, I do this:
> STRUCTURE_HERE *blah = new_structure();
>
> Where in new_structure it has:
> struct = alloc_perm( sizeof(*struct) );
>
> Thank you.