• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: errno in debug vs. release
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: errno in debug vs. release
      • From: "Justin C. Walker" <email@hidden>
    • Re: errno in debug vs. release
      • From: Cameron Hayne <email@hidden>
References: 
 >errno in debug vs. release (From: John W Noerenberg II <email@hidden>)
 >Re: errno in debug vs. release (From: Eric Albert <email@hidden>)

  • Prev by Date: Re: STL vector debugging
  • Next by Date: sharing precompiled headers
  • Previous by thread: Re: errno in debug vs. release
  • Next by thread: Re: errno in debug vs. release
  • Index(es):
    • Date
    • Thread