Re:Nymph: A slightly different version of C
by sqeaky on Friday August 18, 2017 @11:52AM
(#15047259)
You shouldn't new or malloc unless you need to. The more you allocate the more you leak.
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. */
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: