TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Jasen Betts
from: Neil Heller
date: 2003-05-26 11:58:02
subject: FREEing a pointer to a p

NH> Now, after I've used the variables in various (nefarious) ways,
NH> I need to free them.  However, if I go

JB>  NH> free(pbar1->next->charvar);

JB> if it doesn't throw the assertion if you free them immediately after
JB> initialising them the eror must lie in the nefarious code.

JB> Also you should check that each malloc succeeds.

It turned out that I was malloc(ing) strlen(foo) instead of 
strlen(foo)+1.  What really troubles me is why an assert was thrown when 
I attempted to free() the first node of the linked list.

þ CMPQwk 1.42 999

--- Maximus/2 3.01
* Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000)
SEEN-BY: 633/267 270
@PATH: 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.