News for hackers. Stuff that matters.
Re:Ask HN: What are some examples of beautiful software? by lokeshk on Monday March 14, 2016 @12:36PM (#11283795)
Sorry to be a stickler, but the error handling in your method "frees" a resource even when nothing was allocated to it. Freeing a null pointer is as such an undefined behavior.
Re:Ask HN: What are some examples of beautiful software? by Someone on Monday March 14, 2016 @03:32PM (#11284962)
http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1124.pdf, section 7.20.3.2 "The free function":

"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."

Re:Ask HN: What are some examples of beautiful software? by PeCaN on Monday March 14, 2016 @05:00PM (#11285549)
Dereferencing a null pointer is undefined behavior. free() on NULL is defined to be a no-op.