I'm studying for a test and one of the questions was to implement a system like valgrind for Windows.
My fellow students and I were interested in doing the following:

```
void* ptr = malloc(size);
int ptr_location = (int)ptr;
free( (void*) ptr_location);

```

The reason is to easily manage memory by locations and sizes in a map, instead of holding the pointer itself.

Are these conversions legal, and is there a better way to do this?