sds.c no longe pre-allocate more than 1MB of free space ahead. This fixes issue #252.
This commit is contained in:
parent
7faa1f075b
commit
bd068b15c2
@ -116,7 +116,11 @@ 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