[Gc] Determining if pointer GC allocated

Hans Aberg haberg-1 at telia.com
Tue Dec 20 12:25:41 PST 2011


Is there a function to check if a pointer has been allocated by the GC? That is, something like
  bool is_on_heap(void* p);
that returns true exactly when p has been allocated by the GC. And would such a function be time consuming?

Looking through the gh.h header, I could not find it. The background is that the C++ language does not come with a way to determine how an object is allocated. So those that want such a feature would implement it by letting operator new() registering pointers in a table, and do a lookup. Which is essentially the function above.

Hans





More information about the Gc mailing list