You are not freeing up the heap allocation long *p_long = new long; Considering that it is a for loop, you will have orphaned some memory blocks (newed, but no pointers referencing them anymore for delete-ion.)
You have to free p_long in the appropriate part of the loop if it is not assigned to temp. Your continue statement is redundant (maybe you meant break?). Also, the modern version of NULL is nullptr.
Another point is that your if ( p_long ) check is basically only going to be NULL in the case that your current new heap allocator for that type (long) had problems allocating (e.g. out of memory), and that the following if ( 0 == *p_long ) is checking that the newly allocated long was automatically initialised with a value of 0. AFAIK this is not the case, since in C++, you only pay in performance for what you need. The value is undefined (in reality it will probably be the existing, untampered value at that memory address).