MCPcopy Create free account
hub / github.com/antirez/botlib / sdsgrowzero

Function sdsgrowzero

sds.c:379–390  ·  view source on GitHub ↗

Grow the sds to have the specified length. Bytes that were not part of * the original length of the sds will be set to zero. * * if the specified length is smaller than the current length, no operation * is performed. */

Source from the content-addressed store, hash-verified

377 * if the specified length is smaller than the current length, no operation
378 * is performed. */
379sds sdsgrowzero(sds s, size_t len) {
380 size_t curlen = sdslen(s);
381
382 if (len <= curlen) return s;
383 s = sdsMakeRoomFor(s,len-curlen);
384 if (s == NULL) return NULL;
385
386 /* Make sure added region doesn't contain garbage */
387 memset(s+curlen,0,(len-curlen+1)); /* also set trailing \0 byte */
388 sdssetlen(s, len);
389 return s;
390}
391
392/* Append the specified binary-safe string pointed by 't' of 'len' bytes to the
393 * end of the specified sds string 's'.

Callers

nothing calls this directly

Calls 3

sdslenFunction · 0.85
sdsMakeRoomForFunction · 0.85
sdssetlenFunction · 0.85

Tested by

no test coverage detected