• 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: Cameron Hayne <email@hidden>
  • Date: Tue, 7 Feb 2006 18:12:22 -0500

On 7-Feb-06, at 5:10 PM, John W Noerenberg II wrote:

But malloc *is* supposed to set errno* if the size argument equals zero.

I'm not sure where you are getting that from. I don't see it on the man page.
And the following program works fine - as I think it should.


#include <stdio.h>
#include <stdlib.h>
#include <sys/errno.h>

int main()
{
    char *ptr;

    /* Set errno to something recognizable */
    errno = 31415926;
    printf("errno was set to %d\n", errno);

    ptr = malloc(0);
    if (ptr == NULL)
    {
        printf("malloc returned NULL, errno is %d\n", errno);
    }
    else
    {
	printf("malloc succeeded - returned %x, errno is %d\n", ptr, errno);
    }

    return 0;
}

--
Cameron Hayne
email@hidden


_______________________________________________ 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: John W Noerenberg II <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>)
 >Re: errno in debug vs. release (From: John W Noerenberg II <email@hidden>)

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