malloc.h is still legitimate after all

Brooks Davis brooks at one-eyed-alien.net
Tue Feb 21 11:12:33 PST 2006


On Tue, Feb 21, 2006 at 07:49:48PM +0100, pfgshield-freebsd at yahoo.com wrote:
> Hi;
> I was porting some parts of COIN-OR (some Operations Research packages
> opensourced by IBM a while ago), and when I was happily suggesting that all
> occurences of malloc.h should be removed and/or replaced with stdlib.h I got
> this reply:

The author is wrong.  He's unconditionally including a non-standard
header file in order to obtain a non-standard structure.  Specificaly,
there is no mallinfo structure on FreeBSD so he can apply what ever
conditional he uses around that code around the include of malloc.h.
You can verify the lock of mallinfo struct with this command:

find /usr/include -type f | xargs grep mallinfo

-- Brooks

> ______________
> Pedro, 
> 
> The mallinfo struct that ReportMemory uses is defined in malloc.h, and not
> brought in by stdlib.h. 
> 
> I'm testing on AIXv5.1, __STDC__ is defined, and "struct mallinfo" is unknown
> if I don't include malloc.h. 
> 
> I don't know enough about the different flavors of UNIX (System V, POSIX, BSD?)
> to know what to do that satisfies all. 
> 
> The AIX docs say 
> 
>   "The mallopt and mallinfo subroutines are provided for source-level
> compatibility with the System V malloc subroutine " 
> 
> The gnu gcc docs say 
> 
> "This function and its associated data type are declared in `malloc.h'; they
> are an extension of the standard SVID/XPG version." 
> ...
> ___________
> 
> So malloc.h will no be removed from the package but rather it will be undef'd
> __FreeBSD__ and the package will still work on FreeBSD. I doubt we will ever
> add these extensions, but there's also a glibc port for FreeBSD now so maybe
> __FreeBSD__ is not the correct variable here.
> 
> I personally think the FreeBSD port's people have contributed greatly to clean
> inappropiate uses of malloc.h in the software world, but perhaps an error is
> too drastic and we should fall back to a warning.
> 
> cheers,
> 
>     Pedro.
> 
> 
> ---
>      Pedro F. Giffuni
>      M. Sc. Industrial Eng. University of Pittsburgh
>      Mech. Eng.      Universidad Nacional de Colombia
> ---
> Yahoo is powered by FreeBSD    http://www.FreeBSD.org/
> 
> 
> 	
> 
> 	
> 		
> ___________________________________ 
> Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
> http://mail.yahoo.it
> _______________________________________________
> freebsd-standards at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-standards
> To unsubscribe, send any mail to "freebsd-standards-unsubscribe at freebsd.org"
-- 
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-standards/attachments/20060221/4a9a4f3a/attachment.bin


More information about the freebsd-standards mailing list