| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | FREEing a pointer to a p |
Given the following code:
typedef struct foostruct {
struct foostruct * next;
char * charvar;
int intval;
} foo;
int main(void)
{
foo * pbar1 = (foo *)malloc(sizeof(foo));
pbar1->next = (foo *)malloc(sizeof(foo));
pbar1->next->charvar = (char *)malloc(strlen(SomeString)+1);
strcpy(pbar1->next->charvar, SomeString);
Now, after I've used the variables in various (nefarious) ways, I need
to free them. However, if I go
free(pbar1->next->charvar);
the system (in debug mode) throws an assertion. Does anybody have an
idea why?
þ 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™.