I am creating scripting language. When I allocate thing ,it\'s allocate the thing and returns the address and then I do whatever with it and then delete it. I can\'t contro
The simplest solution is to use a map. The map should be indexed by a pointer to the object, likely as a void *
. The contents of the map item should be the type of object created.
Any time a script creates an object, add an entry to the map. Any time a script deletes an object, remove the map entry. When a script accesses an object, find the pointer in the map, thus confirming both that it exists and that the type is correct.