delete a pointer after it was assigned the return of a strdup()?

Started by
1 comment, last by GekkoCube 20 years, 6 months ago
is this necessary? after i started using strdup in conjunction with modal dialog''s in an mfc program my program starts to crash when i exit.
Advertisement
You tell us. You''re the one with the application sitting right in front of you.

char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/
If you looked at the definition of strdup(), you would see that it should be followed by a call to free() when you no longer need the string. A memory leak should not crash your program upon exit but calling delete[] instead of free() on the allocated string might.

This topic is closed to new replies.

Advertisement