sds copies uninitialized data wasting time for everyone
Former-commit-id: a1475af1e4ab97337287d4ef08d092ffabbb73ca
This commit is contained in:
parent
a8dacb0046
commit
5ee7a6b8f1
@ -227,7 +227,9 @@ sds sdsMakeRoomFor(sds s, size_t addlen) {
|
|||||||
if (type == SDS_TYPE_5) type = SDS_TYPE_8;
|
if (type == SDS_TYPE_5) type = SDS_TYPE_8;
|
||||||
|
|
||||||
hdrlen = sdsHdrSize(type);
|
hdrlen = sdsHdrSize(type);
|
||||||
if (oldtype==type) {
|
if (oldtype==type && (len+1024) >= avail) {
|
||||||
|
// note: if we have a lot of free space don't use this as we don't want s_realloc copying
|
||||||
|
// uninitialized data
|
||||||
newsh = s_realloc(sh, hdrlen+newlen+1, MALLOC_SHARED);
|
newsh = s_realloc(sh, hdrlen+newlen+1, MALLOC_SHARED);
|
||||||
if (newsh == NULL) return NULL;
|
if (newsh == NULL) return NULL;
|
||||||
s = (char*)newsh+hdrlen;
|
s = (char*)newsh+hdrlen;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user