On Wed, Mar 09, 2005, Orna Agmon wrote about "RE: [Haifux] c with a spoon and 
pointer arithmetic":
> The question was: what is the exact type of error created?
> Orna.

In the classic Unix implementation, the behavior is "undefined". Anything
might happen. Everything might work well, the free() itself might cause
a memory fault (segmentation violation), the usage of the memory afterward
might cause a memory fault, some unrelated future malloc() or free() call
will cause a memory fault, or some unrelated memory area might get corrupted
without a memory fault.

What doesn't happen is that free doesn't return an error. It can't - it's
of void type.

There are "debugging malloc" libraries, and various tools, which try to help
you catch such errors.

-- 
Nadav Har'El                        |    Wednesday, Mar 9 2005, 28 Adar I 5765
[EMAIL PROTECTED]             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Everybody lies, but it doesn't matter
http://nadav.harel.org.il           |since nobody listens.

--------------------------------------------------------------------------
Haifa Linux Club Mailing List (http://www.haifux.org)
To unsub send an empty message to [EMAIL PROTECTED]


Reply via email to