4 ms·
Show HN: I rewrote few of the common core string.h functions
I rewrote the most common core string.h functions in pure C. I mostly did it to learn pointers and string. Would love to get any feedbacks:)
- gthompson512 1y agoDepending on what exactly you are trying to learn from this, I would recommend looking at the source for musl like https://git.musl-libc.org/cgit/musl/tree/src/string https://git.musl-libc.org/cgit/musl/tree/src/string and trying to understand why it looks so much more complicated than the simple implementation.
- TheSoftwareGuy 1y agoIs this meant to be used in production systems, or is it just a learning exercise?
- mparnisari 1y agohow do you know that the implementation is correct? i don't see tests
- trollied 1y agoLook at glibc. eg: https://github.com/lattera/glibc/blob/master/string/strcpy.c https://github.com/lattera/glibc/blob/master/string/strcpy.c
- secondcoming 1y agostrcmp doesn’t return a bool.
- dvh 1y agoI would rather see some novel, simple, easy to use c string library.
- lelanthran 1y ago> I would rather see some novel, simple, easy to use c string library. I dunno about novel, I have used (some of) these functions extensively: https://github.com/lelanthran/libds/blob/master/src/ds_str.h https://github.com/lelanthran/libds/blob/master/src/ds_str.h
- deepvinci 1y agowhat does easy means here? can you elaborate?
- nemothekid 1y ago`r_strlen` truncates the output length on 64bit systems (size_t is 64 bits while int is 32 bits). You should be compiling with -Wall -Werror.
- bsima 1y agoIf you specifically want code review, consider submitting the code to the code review SE https://codereview.stackexchange.com/ https://codereview.stackexchange.com/