Click to See Complete Forum and Search --> : looking behind the scenes
threadhead
06-15-2003, 05:07 PM
heyho there!
a few minutes ago i read the manual page of malloc.
i saw that you need to include stdlib.h in order to use the malloc() function.
then i took a look into the stdlib.h file and found something like
"extern void *malloc(blabla...)"
--
where do i find, how the function really works?
something like:
char malloc (size_t bytes)
{
...
}
thanks
Strogian
06-15-2003, 09:01 PM
malloc is defined, probably in a source .c file, somewhere in glibc. I keep the sources of everything (including glibc) around in case I want to find something like that. I'll bet you can find it online somewhere, though. (I know there are sites where you can search for anything defined for the kernel)
mrbl0nde
06-15-2003, 10:33 PM
i think this is what you are looking for
http://www.micro.uqam.ca/Ressource/introl/Libraries/C/ANSI_C/malloc.c
threadhead
06-16-2003, 06:08 AM
thanks, that is exactly was i have been looking for. :)
but where do i find glibc on my box?
or do i have to choose a special option when compiling my kernel?
Stuka
06-16-2003, 10:11 AM
malloc.c is in your kernel source tree - if you do a find from the top level of your kernel source, you'll find it somewhere, I'm sure.
Strogian
06-16-2003, 10:39 AM
Originally posted by Stuka
malloc.c is in your kernel source tree - if you do a find from the top level of your kernel source, you'll find it somewhere, I'm sure.
Oh ok, didn't realize that... :)
If it were actually in glibc though, you'd have to have the sources for glibc laying around somewhere. Normally, all you have are the compiled libraries (.a and .so files), which are directly linked to other programs. If you wanted it's source, you could get it from ftp://ftp.gnu.org/gnu/glibc/
threadhead
06-16-2003, 02:53 PM
thanks for the links. ;)