且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是挂钩的malloc的目的是什么?

更新时间:2022-05-13 22:24:30

好吧,如果你可以挂接到分配函数的行为,那么你就可以跟踪内存分配的分析和调试。

Well, if you can hook into the behaviour of allocation functions, then you can track memory allocations for profiling and debugging.

上的malloc挂钩GCC的文档具有一个可爱的小例如展示每次分配函数被调用时添加调试输出。

The GCC documentation on malloc hooks has a nice little example demonstrating adding debug output every time the allocation functions are invoked.

我真的不知道还有什么要告诉你......是不是足够的理由?

I'm not really sure what else to tell you... is that not reason enough?