MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / sdsgrowzero

Function sdsgrowzero

src/util/sds/sds.c:377–388  ·  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

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