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

Function sdsupdatelen

app/redis-6.2.6/src/sds.c:213–216  ·  view source on GitHub ↗

Set the sds string length to the length as obtained with strlen(), so * considering as content only up to the first null term character. * * This function is useful when the sds string is hacked manually in some * way, like in the following example: * * s = sdsnew("foobar"); * s[2] = '\0'; * sdsupdatelen(s); * printf("%d\n", sdslen(s)); * * The output will be "2", but if we comment out

Source from the content-addressed store, hash-verified

211 * the output will be "6" as the string was modified but the logical length
212 * remains 6 bytes. */
213void sdsupdatelen(sds s) {
214 size_t reallen = strlen(s);
215 sdssetlen(s, reallen);
216}
217
218/* Modify an sds string in-place to make it empty (zero length).
219 * However all the existing buffer is not discarded but set as free space

Callers

nothing calls this directly

Calls 1

sdssetlenFunction · 0.85

Tested by

no test coverage detected