mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Use unsigned integers in SDS header.
This raises the max string to 4GB without any downside.
This commit is contained in:
parent
cf85b5ba81
commit
68db7b1f56
7
deps/hiredis/sds.c
vendored
7
deps/hiredis/sds.c
vendored
@ -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, ...) {
|
|||||||
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;
|
||||||
|
|
||||||
|
4
deps/hiredis/sds.h
vendored
4
deps/hiredis/sds.h
vendored
@ -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[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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, ...) {
|
|||||||
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;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user