There's no portable way to determine whether a pointer refers to a static or auto variable, or to memory allocated via the *alloc
functions, by looking at the pointer value alone. If you are intimately familiar with the memory model on your platform you could make some educated guesses, but that's about it.
Otherwise, if it matters, you will have to track that information yourself.