Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should Mac OSX have a "malloc.h" file? [duplicate]

A customer's code is expecting to find an include file malloc.h in one of the "usual suspect" locations. On my Mac, AFAICT, there is no malloc.h, at least not in any place you would expect to find it, such as /usr/include, /usr/local/include, or /opt/local/include. Since the malloc() is usually defined in stdlib.h, and since the code includes stdlib.h anyway, I was able to get the code to build by just commenting out the few includes of malloc.h. I am building with gcc.

But two questions: Is my gcc messed up somehow? Should that file be there? Also, the code bombs almost immediately with a seg fault that I haven't been able to track down yet. Could this be the consequence of using the wrong malloc()?

like image 609
bob.sacamento Avatar asked Dec 31 '22 22:12

bob.sacamento


1 Answers

The malloc.h is deprecated and should not be used. It contains some non-standard functions too. If you want to use malloc, then include stdlib.h. Not even the C89 standard mentions malloc.h

If it's the cause of your problems, I don't know, but it's quite probable.

like image 144
klutt Avatar answered Jan 05 '23 16:01

klutt