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

Function sdsupdatelen

sds.c:184–187  ·  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

182 * the output will be "6" as the string was modified but the logical length
183 * remains 6 bytes. */
184void sdsupdatelen(sds s) {
185 size_t reallen = strlen(s);
186 sdssetlen(s, reallen);
187}
188
189/* Modify an sds string in-place to make it empty (zero length).
190 * 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