A question in sdsIncrLen
In the function sdsIncrLen, I think the statement "assert(sh->free >= 0) " is redundant, because "assert(sh->free >= incr)" makes sure this situation would not happen.
void sdsIncrLen(sds s, int incr) { struct sdshdr sh = (void)(s - sizeof *sh); assert(sh->free >= incr); sh->len += incr; sh->free -= incr; assert(sh->free >= 0); s[sh->len] = '\0'; }
Yeah, the only thing that could make it be less than 0 would be in a multithreaded programs where two threads are trying to modify the same string at once, but that’d be very broken.
Anyway, @antirez seems to have no intention of maintaining SDS and I emailed him a couple of months ago about it but he never replied, so I’m working on a fork currently located at https://github.com/yabok/sds, though it will be moved to (most likely) https://github.com/yabok/yasl soon.
See pull request #45 for a fix.
@lemzwerg If you look at the repo history and the other PRs and issues open you can see how it's pretty useless to open a PR on this repo.
Maybe, yes. However, the PRs I produce are just a byproduct and quite easy to generate, so why not. I'm used to normally commit code with associated ChangeLog entries; this essentially means that you have to concisely wrap up your modifications in an atomic way – in most cases this already corresponds to a PR...