1

Is it possible to wrap malloc / free functions in Android NDK?

I have checked all the solutions from create-a-wrapper-function-for-malloc-and-free-in-c but none of them worked.

In the top-voted answer there are 4 approaches proposed:

  1. Usage of hooks -> hooks are not available in bionic
  2. Usage of dlsym -> crashes with 'SEGV_MAPERR'
  3. not applicable for Android
  4. not applicable for Android
Community
  • 1
  • 1
blebleble
  • 424
  • 6
  • 13
  • 1
    ' none of them worked' what?? Why? Not even as a straight pass-through? – Martin James Dec 08 '15 at 09:35
  • Questions seeking debugging help ("**why isn't this code working?**") must include the desired behavior, a *specific problem or error* and *the shortest code necessary* to reproduce it **in the question itself**. Questions without **a clear problem statement** are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – autistic Dec 08 '15 at 09:40
  • 2
    For Android you can use **libc.debug.malloc**: https://source.android.com/devices/tech/debug/native-memory.html – mkmk88 Dec 08 '15 at 09:43
  • *"Is it possible to wrap malloc / free functions in Android NDK?"* - Yes, use C++ :) – Christian Hackl Dec 08 '15 at 11:01

0 Answers0