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. */
| 412 | * if the specified length is smaller than the current length, no operation |
| 413 | * is performed. */ |
| 414 | sds 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'. |
no test coverage detected