Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Good stuff.

Only things I disagree with:

- The out-parameter of strclone. How annoying! I don't think this adds information. Just return a pointer, man. (And instead of defending against the possibility that someone is doing some weird string pooling, how about jut disallow that - malloc and free are your friends.)

- Avoiding void. As mentioned in another comment, it's useful for polymorphism. You can do quite nice polymorphic code in C and then you end up using void a lot.





Yes that section raised my hackles too, to the point where I'm suspicious of the whole article.

The solution, in my opinion, is to either document that strclone()'s return should be free()'d, or alternately add a strfree() declaration to the header (which might just be `#define strfree(x) free(x)`).

Adding a `char **out` arg does not, in my opinion, document that the pointer should be free()'d.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: