You could create a shim for ent_remove...
void _ent_remove_stub(ENTITY *);
void _ent_remove_stub_init()
{
_ent_remove_stub = ent_remove;
}
#define ent_remove(ent) do {if(ent == my){_ent_remove_stub(ent); my = NULL; return;} _ent_remove_stub(ent);} while(0)
Dirty? Check
Untested? Check
Works? Maybe
You just need to call _ent_remove_stub_init() somewhere, possibly before calling ent_remove the first time =/ The intention is to set my to NULL and to leave the function/action before doing any harm with the now dead my ENTITY. You could make it less risky by just calling the define ent_remove_save() or so, but then you had to search and replace code and we are all lazy coders, aren't we? ^^