>C: anything by antirez (redis, etc...) Redis is the epitome of well written understandable C.
The first file I opened has 3 gotos but maybe it's pure randomness... ;p
The first file I opened has 3 gotos but maybe it's pure randomness... ;p
void foo() {
int* foo = malloc(...)
if (foo == NULL) goto err_foo;
int* bar = malloc(...)
if (bar == NULL) goto err_bar;
/* code */
err_bar:
free(bar);
err_foo:
free(foo);
}
That's a use of goto that's often considered non-evil, probably because the alternatives are typically a lot more ugly."The free function causes the space pointed to by ptr to be deallocated, that is, made available for further allocation. If ptr is a null pointer, no action occurs."