code的malloc和free [英] Code for malloc and free

查看:141
本文介绍了code的malloc和free的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里可以找到的malloc的code我的gcc编译器是目前使用?其实我是想写这将是从原来的一点点不同的我自己的malloc函数。我知道我可以使用挂钩等,但是我想看到真正的code。

Where can I find the code for malloc my gcc compiler is using at the moment? I actually want to write my own malloc function which will be a little different from the original one. I know I can use hooks et all, but I want to see the real code.

推荐答案

的malloc的POSIX接口被定义这里

The POSIX interface of malloc is defined here.

如果你想找出的GNU / Linux(glibc的)实现的malloc C库怎么样,去获得的http://ftp.gnu.org/gnu/glibc/ ,并期待在的malloc / malloc.c 文件。

If you want to find out how the C library in GNU/Linux (glibc) implements malloc, go and get the source code from http://ftp.gnu.org/gnu/glibc/ and look at the malloc/malloc.c file.

还有由Doug Lea 的内存分配器的基本文档描述理论的的 M (埃默里大学)的页头(员)(阅读本carrefully,然后再决定是否真的需要实现自己的malloc)。

There is also the base documentation of the Memory Allocator by Doug Lea that describes the theory of a m(emory)alloc(ator) (read this carrefully, and then decide if you really need to implement your own malloc).

这篇关于code的malloc和free的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆