diff options
author | antirez <antirez@gmail.com> | 2014-08-12 15:17:28 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-08-13 10:53:51 +0200 |
commit | 68db7b1f564be07fa98f6102aefb33d941fc2cdc (patch) | |
tree | 8bae1efe4c7d375b6d54b1c29d0c5aae85523f9b /src | |
parent | cf85b5ba812070442c450b5dbc6c5e12a6c0819b (diff) | |
download | redis-68db7b1f564be07fa98f6102aefb33d941fc2cdc.tar.gz |
Use unsigned integers in SDS header.
This raises the max string to 4GB without any downside.
Diffstat (limited to 'src')
-rw-r--r-- | src/sds.c | 7 | ||||
-rw-r--r-- | src/sds.h | 4 |
2 files changed, 7 insertions, 4 deletions
@@ -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); @@ -458,7 +461,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; @@ -39,8 +39,8 @@ typedef char *sds; struct sdshdr { - int len; - int free; + unsigned int len; + unsigned int free; char buf[]; }; |