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. */
| 377 | * if the specified length is smaller than the current length, no operation |
| 378 | * is performed. */ |
| 379 | sds 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'. |
nothing calls this directly
no test coverage detected