by qwertzuiop · 9y ago · 0 comments
Just stack/automatically allocate the resource and take the address with & then pass the pointer around. Because the data is automatically cleaned up you know you won't have any leaks (and certain whole other classes of bugs).
EDIT - Consider:
int myDictLen = 0;
int* myDictLenPtr = &myDictLen;
/* now you can pass around the pointer myDictLenPtr
to functions that can used an int* and it will be
available in this scope and automatically cleaned
up for you. */int var_a = 5;
and use &var_a when you want to acess that variable as a pointer within that scope. Not only is this more efficient, it is much easier to read.