MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sdsgrowzero

Function sdsgrowzero

app/redis-6.2.6/src/sds.c:414–425  ·  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

412 * if the specified length is smaller than the current length, no operation
413 * is performed. */
414sds sdsgrowzero(sds s, size_t len) {
415 size_t curlen = sdslen(s);
416
417 if (len <= curlen) return s;
418 s = sdsMakeRoomFor(s,len-curlen);
419 if (s == NULL) return NULL;
420
421 /* Make sure added region doesn't contain garbage */
422 memset(s+curlen,0,(len-curlen+1)); /* also set trailing \0 byte */
423 sdssetlen(s, len);
424 return s;
425}
426
427/* Append the specified binary-safe string pointed by 't' of 'len' bytes to the
428 * end of the specified sds string 's'.

Callers 4

setrangeCommandFunction · 0.85
clusterSaveConfigFunction · 0.85
RM_StringTruncateFunction · 0.85

Calls 4

sdslenFunction · 0.85
sdsMakeRoomForFunction · 0.85
memsetFunction · 0.85
sdssetlenFunction · 0.85

Tested by

no test coverage detected