What are those, exactly? AFAIK, you can safely track memory addresses by storing them as intptr_t/uintptr_t.
What are those, exactly? AFAIK, you can safely track memory addresses by storing them as intptr_t/uintptr_t.
In particular, casting a pointer to intptr_t, doing arithmetic on it, and casting back is not guaranteed to do anything useful. It almost certainly will, since most systems treat it as roughly the same as casting to char *, but the standard does not guarantee it.
One example of using intptr_t would be going from a pointer passed to free() to a metadata block for the memory that must be freed.
I believe it's implementation-specific, precisely so that malloc/free can be implemented in conformant C.
The only tricky part is how you can "bless" parts of large memory block originally pointed to by void* (returned from mmap(), for example) to safely become ints and char[]s and structs...