Re: errno in debug vs. release
Re: errno in debug vs. release
- Subject: Re: errno in debug vs. release
- From: John W Noerenberg II <email@hidden>
- Date: Tue, 7 Feb 2006 14:10:44 -0800
At 12:52 PM -0800 2/7/06, Eric Albert wrote:
free(3) is not documented to set errno, so there's no guarantee that
errno is actually set at this point in your code. Given that,
you're probably getting a random value for errno. I'd suggest
changing your code to only read errno after making function calls
that are documented as setting it.
You're right about free. But malloc *is* supposed to set errno* if
the size argument equals zero. Also note that even though errno is
set for the debug version, malloc still returns the address of the
heap. So this is a definitely a problem.
*From the malloc man page:
The malloc() function allocates size bytes of memory and returns a
pointer to the allocated memory. malloc() returns a NULL pointer if
there is an error.
--
john noerenberg
----------------------------------------------------------------------
It took long enough in all conscience for realization to come that
the externals of civilization - technology, industry, commerce, and
so on - also require a common basis of intellectual honesty and morality.
-- Herman Hesse, The Glass Bead Game, 1943
----------------------------------------------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden