luffywu / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Suggestion: Why are there only C++ interface in malloc_hook.h and malloc_extension.h ? #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
  There are great C-compatible interfaces in heap-profiler.h and
profiler.h. But why are there only C++ interface in malloc_hook.h and
malloc_extension.h ?

Original issue reported on code.google.com by lxu4...@gmail.com on 24 Jun 2008 at 12:29

GoogleCodeExporter commented 9 years ago
It's a fair question.  The C-compatible interfaces were added to 
heap-profiler.h and
profiler.h more or less at the last minute, when we realized it was easy to do 
so. 
Originally, we had developed tcmalloc as a c++-only application.  You still see 
the
legacy of that in malloc_hook and malloc_extension, which were designed to use 
the
capabilities of C++, and weren't easy to make a "C" interface for like the cpu
profiler and heap profiler (with their much simpler APIs).

With a recent refactoring of the malloc_hook code, it's actually pretty easy to 
make
that "C"-accessible; I'll see if I can do that for the next release. 
malloc_extension.h is much more difficult -- it uses virtual inheritence to 
support
multiple memory allocators.  But I may be able to do something there as well; 
I'll
discuss that with some of the other folks here.

Original comment by csilv...@gmail.com on 25 Jun 2008 at 12:10

GoogleCodeExporter commented 9 years ago
This was added in perftools 0.99, just released.

Original comment by csilv...@gmail.com on 19 Sep 2008 at 8:09