Prob with free()
At the begining of the prog, I allocate 64000:
unsigned char *buffer = (unsigned char*)malloc(64000);
and it frees it at when ending:
free(buffer);
and I compile it with DJGPP...
and I run the prog....
and sometimes the prog crashes
general protection fault
exeption 13...
etc...
why?
I don''t understand what''s wrong...
please help me
creativity is the key:)
Check some of this common errors :
- Do you free() it more than one time ? This is not good!
- Do you use buffer after you freed it ?
Moreover, you should check the return value of malloc(). If buffer = NULL then it wasn''t allocated and freeing it could be harmful.
How long is your source code ? If it''s short (and if you don''t care of course), post it or mail it to me (benjamin.karaban@laposte.net)
Prosper / LOADED corporation
- Do you free() it more than one time ? This is not good!
- Do you use buffer after you freed it ?
Moreover, you should check the return value of malloc(). If buffer = NULL then it wasn''t allocated and freeing it could be harmful.
How long is your source code ? If it''s short (and if you don''t care of course), post it or mail it to me (benjamin.karaban@laposte.net)
Prosper / LOADED corporation
OK
thanx man
I think it was what you said
so I wrote:
if((unsigned char *buffer=(unsigned char *)malloc(64000)) == NULL) return 0;
and I havent any probs actually...
et merci beaucoup
hehe
bye
thanx man
I think it was what you said
so I wrote:
if((unsigned char *buffer=(unsigned char *)malloc(64000)) == NULL) return 0;
and I havent any probs actually...
et merci beaucoup
hehe
bye
creativity is the key:)
Yep, it is important! to say the least that you check return values of things like MALLOC, reads, writes, infact anything in which could result in you reading or writing to a null pointer.
Doing so will seggy everytime.
Doing so will seggy everytime.
-----------------------------------------------All messages are of my own personal opinion and not meant to offend. But if they do - tough :)Neuro.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement