summaryrefslogtreecommitdiff
path: root/deps/hiredis
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-08-12 15:17:28 +0200
committerantirez <antirez@gmail.com>2014-08-13 10:53:51 +0200
commit68db7b1f564be07fa98f6102aefb33d941fc2cdc (patch)
tree8bae1efe4c7d375b6d54b1c29d0c5aae85523f9b /deps/hiredis
parentcf85b5ba812070442c450b5dbc6c5e12a6c0819b (diff)
downloadredis-68db7b1f564be07fa98f6102aefb33d941fc2cdc.tar.gz
Use unsigned integers in SDS header.
This raises the max string to 4GB without any downside.
Diffstat (limited to 'deps/hiredis')
-rw-r--r--deps/hiredis/sds.c9
-rw-r--r--deps/hiredis/sds.h4
2 files changed, 8 insertions, 5 deletions
diff --git a/deps/hiredis/sds.c b/deps/hiredis/sds.c
index 47b9823ea..4af9961ad 100644
--- a/deps/hiredis/sds.c
+++ b/deps/hiredis/sds.c
@@ -123,7 +123,7 @@ void sdsclear(sds s) {
/* Enlarge the free space at the end of the sds string so that the caller
* is sure that after calling this function can overwrite up to addlen
* bytes after the end of the string, plus one more byte for nul term.
- *
+ *
* Note: this does not change the *length* of the sds string as returned
* by sdslen(), but only the free buffer space we have. */
sds sdsMakeRoomFor(sds s, size_t addlen) {
@@ -200,7 +200,10 @@ size_t sdsAllocSize(sds s) {
void sdsIncrLen(sds s, int incr) {
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->free -= incr;
assert(sh->free >= 0);
@@ -457,7 +460,7 @@ sds sdscatfmt(sds s, char const *fmt, ...) {
i = initlen; /* Position of the next byte to write to dest str. */
while(*f) {
char next, *str;
- int l;
+ unsigned int l;
long long num;
unsigned long long unum;
diff --git a/deps/hiredis/sds.h b/deps/hiredis/sds.h
index 9a604021c..37aaf7a28 100644
--- a/deps/hiredis/sds.h
+++ b/deps/hiredis/sds.h
@@ -39,8 +39,8 @@
typedef char *sds;
struct sdshdr {
- int len;
- int free;
+ unsigned int len;
+ unsigned int free;
char buf[];
};