malloc and free

A

ala

I have something near to this:

unsigned *p, *a;
p = malloc(80*sizeof(unsigned));
a=p;
if(p==0) exit(1);
<code snip>
/******************/
free(p);
/******************/
Is it possible there is segmentation fault where there is free(p);?
Where is the error if 'p' is the same of 'a' (p==a) and never I had
free (or realloc) p? How detect *where* I wrote the malloc's memory
not in my space allocated?
Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top