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
68db7b1f
Commit
68db7b1f
authored
Aug 12, 2014
by
antirez
Browse files
Use unsigned integers in SDS header.
This raises the max string to 4GB without any downside.
parent
cf85b5ba
Changes
4
Show whitespace changes
Inline
Side-by-side
deps/hiredis/sds.c
View file @
68db7b1f
...
@@ -200,7 +200,10 @@ size_t sdsAllocSize(sds s) {
...
@@ -200,7 +200,10 @@ size_t sdsAllocSize(sds s) {
void
sdsIncrLen
(
sds
s
,
int
incr
)
{
void
sdsIncrLen
(
sds
s
,
int
incr
)
{
struct
sdshdr
*
sh
=
(
void
*
)
(
s
-
(
sizeof
(
struct
sdshdr
)));
struct
sdshdr
*
sh
=
(
void
*
)
(
s
-
(
sizeof
(
struct
sdshdr
)));
assert
(
sh
->
free
>=
incr
);
if
(
incr
>=
0
)
assert
(
sh
->
free
>=
(
unsigned
int
)
incr
);
else
assert
(
sh
->
len
>=
(
unsigned
int
)(
-
incr
));
sh
->
len
+=
incr
;
sh
->
len
+=
incr
;
sh
->
free
-=
incr
;
sh
->
free
-=
incr
;
assert
(
sh
->
free
>=
0
);
assert
(
sh
->
free
>=
0
);
...
@@ -457,7 +460,7 @@ sds sdscatfmt(sds s, char const *fmt, ...) {
...
@@ -457,7 +460,7 @@ sds sdscatfmt(sds s, char const *fmt, ...) {
i
=
initlen
;
/* Position of the next byte to write to dest str. */
i
=
initlen
;
/* Position of the next byte to write to dest str. */
while
(
*
f
)
{
while
(
*
f
)
{
char
next
,
*
str
;
char
next
,
*
str
;
int
l
;
unsigned
int
l
;
long
long
num
;
long
long
num
;
unsigned
long
long
unum
;
unsigned
long
long
unum
;
...
...
deps/hiredis/sds.h
View file @
68db7b1f
...
@@ -39,8 +39,8 @@
...
@@ -39,8 +39,8 @@
typedef
char
*
sds
;
typedef
char
*
sds
;
struct
sdshdr
{
struct
sdshdr
{
int
len
;
unsigned
int
len
;
int
free
;
unsigned
int
free
;
char
buf
[];
char
buf
[];
};
};
...
...
src/sds.c
View file @
68db7b1f
...
@@ -200,7 +200,10 @@ size_t sdsAllocSize(sds s) {
...
@@ -200,7 +200,10 @@ size_t sdsAllocSize(sds s) {
void
sdsIncrLen
(
sds
s
,
int
incr
)
{
void
sdsIncrLen
(
sds
s
,
int
incr
)
{
struct
sdshdr
*
sh
=
(
void
*
)
(
s
-
(
sizeof
(
struct
sdshdr
)));
struct
sdshdr
*
sh
=
(
void
*
)
(
s
-
(
sizeof
(
struct
sdshdr
)));
assert
(
sh
->
free
>=
incr
);
if
(
incr
>=
0
)
assert
(
sh
->
free
>=
(
unsigned
int
)
incr
);
else
assert
(
sh
->
len
>=
(
unsigned
int
)(
-
incr
));
sh
->
len
+=
incr
;
sh
->
len
+=
incr
;
sh
->
free
-=
incr
;
sh
->
free
-=
incr
;
assert
(
sh
->
free
>=
0
);
assert
(
sh
->
free
>=
0
);
...
@@ -458,7 +461,7 @@ sds sdscatfmt(sds s, char const *fmt, ...) {
...
@@ -458,7 +461,7 @@ sds sdscatfmt(sds s, char const *fmt, ...) {
i
=
initlen
;
/* Position of the next byte to write to dest str. */
i
=
initlen
;
/* Position of the next byte to write to dest str. */
while
(
*
f
)
{
while
(
*
f
)
{
char
next
,
*
str
;
char
next
,
*
str
;
int
l
;
unsigned
int
l
;
long
long
num
;
long
long
num
;
unsigned
long
long
unum
;
unsigned
long
long
unum
;
...
...
src/sds.h
View file @
68db7b1f
...
@@ -39,8 +39,8 @@
...
@@ -39,8 +39,8 @@
typedef
char
*
sds
;
typedef
char
*
sds
;
struct
sdshdr
{
struct
sdshdr
{
int
len
;
unsigned
int
len
;
int
free
;
unsigned
int
free
;
char
buf
[];
char
buf
[];
};
};
...
...
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