Put the pointer in a hash array. The integer then refers to a point in the hash array. The pointer associated with the integer can then be freed and nilled.

You'd need to give us a better code snippet to better understand.

PS. Why not use a pointer instead of an integer. Then you dont need to do the lookup.