<p>Given a pointer to some variable.. is there a way to check whether it was statically or dynamically allocated??  </p>

Can you hook into malloc() itself, like the malloc debuggers do, using LD_PRELOAD or something? If so, you could keep a table of all the allocated pointers and use that. Otherwise, I'm not sure. Is there a way to get at malloc's bookkeeping information?