mirror of
https://github.com/fluencelabs/redis
synced 2025-05-01 05:22:13 +00:00
sds.c no longe pre-allocate more than 1MB of free space ahead. This fixes issue #252.
This commit is contained in:
parent
1cd0cdd523
commit
0b73cbb69f
@ -107,7 +107,11 @@ static sds sdsMakeRoomFor(sds s, size_t addlen) {
|
|||||||
if (free >= addlen) return s;
|
if (free >= addlen) return s;
|
||||||
len = sdslen(s);
|
len = sdslen(s);
|
||||||
sh = (void*) (s-(sizeof(struct sdshdr)));
|
sh = (void*) (s-(sizeof(struct sdshdr)));
|
||||||
newlen = (len+addlen)*2;
|
newlen = (len+addlen);
|
||||||
|
if (newlen < SDS_MAX_PREALLOC)
|
||||||
|
newlen *= 2;
|
||||||
|
else
|
||||||
|
newlen += SDS_MAX_PREALLOC;
|
||||||
newsh = zrealloc(sh, sizeof(struct sdshdr)+newlen+1);
|
newsh = zrealloc(sh, sizeof(struct sdshdr)+newlen+1);
|
||||||
#ifdef SDS_ABORT_ON_OOM
|
#ifdef SDS_ABORT_ON_OOM
|
||||||
if (newsh == NULL) sdsOomAbort();
|
if (newsh == NULL) sdsOomAbort();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user