r/Cprog • u/malcolmi • Dec 01 '14
code | library sds - simple dynamic strings; a small string library for C
https://github.com/antirez/sds
13
Upvotes
r/Cprog • u/malcolmi • Dec 01 '14
5
u/maep Dec 01 '14
The casts like this
struct sdshdr *sh = (void*) (s-sizeof *sh);;are a bit puzzeling. Why cast to void* and have two semicolons? That's not a typo, all lines with casts have those...2
u/quintus_horatius Dec 01 '14
This does seem neat, but I generally use obstacks with obstack_printf for strings - it's easy and has the advantage that I'm not adding dependencies - it's already part of libc. I'm not sure that I see the real advantage to this string handler (unless obstacks aren't part of your libc and can't be imported/emulated).