Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: including sys/malloc.h produces errors?



I am dealing with various programs that simply use malloc to allocate
various structures as needed for dynamic data storage.
So the question boils down to, if you have something like

#include <malloc.h>
....

MYstruct *p = malloc(sizeof(MYstruct));
....
free(p);
....

What is the best "standard/correct/portable" header to include instead of
malloc.h ?


--
Jerry Pendergraft email@hidden
Endocardial Solutions voice: 651-523-6935
1350 Energy Lane, Suite 110 fax: 651-644-7897
St Paul, MN 55108-5254 mobile: 651-491-0163

On Tue, 3 Feb 2004, Justin Walker wrote:

> On Tuesday, February 3, 2004, at 12:02 PM, Jerry Pendergraft wrote:
>
> > I am in the process of converting code that uses malloc.h to include
> > stdlib.h instead. It provides the prototype OK.
> > Is that the right thing to do?
>
> Kind of hard to answer a question like that in a vacuum (no source to
> look at; *not* that I'm asking for same, mind you :-}).
>
> Generally, there are other 'standard' headers that take the place of
> 'malloc.h'. Whether 'stdlib.h' is the one you want depends on what you
> needed from 'malloc.h' and what is present in 'stdlib.h', and I don't
> know what you needed. However, if it compiles without complaints and
> works as you expect, that is a good sign that you are on the right
> track :-}
>
> Regards,
>
> Justin
>
> --
> Justin C. Walker, Curmudgeon-At-Large *
> Institute for General Semantics | "Weaseling out of things is
> what
> | separates us from the animals.
> | Well, except the weasel."
> | - Homer J Simpson
> *--------------------------------------*-------------------------------*
> _______________________________________________
> darwin-development mailing list | email@hidden
> Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: including sys/malloc.h produces errors? (From: Justin Walker <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.