14

I am amazed that I can't find any document stating the difference between _int_malloc and malloc in the output of Valgrind's callgrind tool.

Could anybody explain what's their difference?

Furthermore, I actually write C++ code, so I am using exclusively new not malloc, but in the callgrind output only mallocs are showing up.

Phil Miller
  • 32,214
  • 11
  • 62
  • 86
user695652
  • 3,725
  • 3
  • 32
  • 52

1 Answers1

3

The malloc listed in the callgrind output will be the implementation of malloc provided by the glibc function __libc_malloc in the file glibc/malloc/malloc.c.

This function calls another function, intended for internal use only, named _int_malloc, which does most of the hard work.

As writing standard libraries is very difficult, the authors must be very good programmers and therefore very lazy. So, instead of writing memory allocation code twice, the new operator calls malloc in order to get the memory it requires.

andypea
  • 1,153
  • 7
  • 19