}
/* Grow the sds to have the specified length. Bytes that were not part of
- * the original length of the sds will be set to NULL. */
-sds sdsgrowsafe(sds s, size_t len) {
+ * the original length of the sds will be set to zero. */
+sds sdsgrowzero(sds s, size_t len) {
struct sdshdr *sh = (void*)(s-(sizeof(struct sdshdr)));
size_t totlen, curlen = sh->len;
/* Make sure added region doesn't contain garbage */
sh = (void*)(s-(sizeof(struct sdshdr)));
- memset(s+curlen,0,(len-curlen+1)); /* also set trailing NULL byte */
+ memset(s+curlen,0,(len-curlen+1)); /* also set trailing \0 byte */
totlen = sh->len+sh->free;
sh->len = len;
sh->free = totlen-sh->len;
#ifdef SDS_ABORT_ON_OOM
if (tokens == NULL) sdsOomAbort();
#endif
- if (seplen < 1 || len < 0 || tokens == NULL) return NULL;
+ if (seplen < 1 || len < 0 || tokens == NULL) {
+ *count = 0;
+ return NULL;
+ }
if (len == 0) {
*count = 0;
return tokens;
int i;
for (i = 0; i < elements; i++) sdsfree(tokens[i]);
zfree(tokens);
+ *count = 0;
return NULL;
}
#endif