I'm writing a program to overload the new and delete operators. I'm doing this so that every time the new operator is called, it saves the info of the new pointer, along with its size in a map.
map<void*, size_t>
The problem that I am having, though, is that there is something wrong with the void pointer that I am creating using the malloc function. When I try to add these void pointers to my map, my program gets a EXC_BAD_ACCESS error. How can I add these newly allocated void pointers to my map without getting that error? Here's my program:
So you want to supply a global replacement for new and you want your replacement to add the new pointer to a map. Do you think new gets called when adding something to a map?