C++ Invalid pointer values
c++, pointers
Solution
I would suggest just using a struct that contains a pointer and an enum. But if for some reason that's inconvenient, just allocate some small structures and use their addresses just to indicate magic pointer values. (Of course, don't ever free them.)
You can also use the address of static objects. Like this:
static int chunk_not_loaded_i, chunk_empty_i, chunk_full_i;
void *chunk_not_loaded = &chunk_not_loaded_i;
void *chunk_full = &chunk_full_i;
if (some_chunk == chunk_not_loaded)
...
Problem
I would like to know which pointer values are invalid so i would not have to allocate new memory just to mark special chunk states(Memory consumption is critical). So i could use them for special states like - 0x00000000 - would mean chunk is not loaded - 0x00000001 - would mean chunk is empty - 0x00000002 - chunk is full. And when some real stuff needs to be saved to the memory i would do new Chunk(...);