Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
0b73cbb6
Commit
0b73cbb6
authored
Jan 16, 2012
by
antirez
Browse files
sds.c no longe pre-allocate more than 1MB of free space ahead. This fixes issue #252.
parent
1cd0cdd5
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/sds.c
View file @
0b73cbb6
...
@@ -107,7 +107,11 @@ static sds sdsMakeRoomFor(sds s, size_t addlen) {
...
@@ -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
();
...
...
src/sds.h
View file @
0b73cbb6
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
#ifndef __SDS_H
#ifndef __SDS_H
#define __SDS_H
#define __SDS_H
#define SDS_MAX_PREALLOC (1024*1024)
#include <sys/types.h>
#include <sys/types.h>
#include <stdarg.h>
#include <stdarg.h>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment