4 ms·
Here's an example: void do_stuff(char *name) { char *my_name = strdup(name); if (condition_signalling_no_work()) goto done; if (do_
by sjs 15y ago
Here's an example:
void do_stuff(char *name) {
char *my_name = strdup(name);
if (condition_signalling_no_work()) goto done;
if (do_something_with(my_name)) goto done;
...
done:
free(my_name);
return;
}
If it helps think of it as a finally block. The function does some things and no matter what it has to run that block at the end.
- Peaker 15y agoAh, so for resource cleanup in general, not memory management in particular.