how to determine if an object was allocated on the heap
is there a C or C++ standard library function to determine if a pointer points to an object that was allocated on the heap via malloc() or new? I suspect it would be platform/implementation dependent, but I was just curious about this.
char* foo = new char;
char* bar = foo + 23;
char* baz = is_heap_ptr(bar); // returns a pointer to the base of the allocated block (foo) if bar is on the heap, NULL otherwise;