This commit is contained in:
artikell 2024-04-19 23:04:41 +08:00 committed by GitHub
commit 9d12ec62af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 26 deletions

View File

@ -1930,7 +1930,7 @@ int listpackTest(int argc, char *argv[], int flags) {
assert(lpLength(lp) == 0);
assert(lp[LP_HDR_SIZE] == LP_EOF);
assert(lpBytes(lp) == (LP_HDR_SIZE + 1));
zfree(lp);
lpFree(lp);
lp = createList();
unsigned char *ptr = lpFirst(lp);
@ -1938,7 +1938,7 @@ int listpackTest(int argc, char *argv[], int flags) {
assert(lpLength(lp) == 0);
assert(lp[LP_HDR_SIZE] == LP_EOF);
assert(lpBytes(lp) == (LP_HDR_SIZE + 1));
zfree(lp);
lpFree(lp);
}
TEST("Delete whole listpack with negative index");
@ -1948,7 +1948,7 @@ int listpackTest(int argc, char *argv[], int flags) {
assert(lpLength(lp) == 0);
assert(lp[LP_HDR_SIZE] == LP_EOF);
assert(lpBytes(lp) == (LP_HDR_SIZE + 1));
zfree(lp);
lpFree(lp);
lp = createList();
unsigned char *ptr = lpSeek(lp, -4);
@ -1956,7 +1956,7 @@ int listpackTest(int argc, char *argv[], int flags) {
assert(lpLength(lp) == 0);
assert(lp[LP_HDR_SIZE] == LP_EOF);
assert(lpBytes(lp) == (LP_HDR_SIZE + 1));
zfree(lp);
lpFree(lp);
}
TEST("Delete inclusive range 0,0");
@ -1965,14 +1965,14 @@ int listpackTest(int argc, char *argv[], int flags) {
lp = lpDeleteRange(lp, 0, 1);
assert(lpLength(lp) == 3);
assert(lpSkip(lpLast(lp))[0] == LP_EOF); /* check set LP_EOF correctly */
zfree(lp);
lpFree(lp);
lp = createList();
unsigned char *ptr = lpFirst(lp);
lp = lpDeleteRangeWithEntry(lp, &ptr, 1);
assert(lpLength(lp) == 3);
assert(lpSkip(lpLast(lp))[0] == LP_EOF); /* check set LP_EOF correctly */
zfree(lp);
lpFree(lp);
}
TEST("Delete inclusive range 0,1");
@ -1981,14 +1981,14 @@ int listpackTest(int argc, char *argv[], int flags) {
lp = lpDeleteRange(lp, 0, 2);
assert(lpLength(lp) == 2);
verifyEntry(lpFirst(lp), (unsigned char*)mixlist[2], strlen(mixlist[2]));
zfree(lp);
lpFree(lp);
lp = createList();
unsigned char *ptr = lpFirst(lp);
lp = lpDeleteRangeWithEntry(lp, &ptr, 2);
assert(lpLength(lp) == 2);
verifyEntry(lpFirst(lp), (unsigned char*)mixlist[2], strlen(mixlist[2]));
zfree(lp);
lpFree(lp);
}
TEST("Delete inclusive range 1,2");
@ -1997,14 +1997,14 @@ int listpackTest(int argc, char *argv[], int flags) {
lp = lpDeleteRange(lp, 1, 2);
assert(lpLength(lp) == 2);
verifyEntry(lpFirst(lp), (unsigned char*)mixlist[0], strlen(mixlist[0]));
zfree(lp);
lpFree(lp);
lp = createList();
unsigned char *ptr = lpSeek(lp, 1);
lp = lpDeleteRangeWithEntry(lp, &ptr, 2);
assert(lpLength(lp) == 2);
verifyEntry(lpFirst(lp), (unsigned char*)mixlist[0], strlen(mixlist[0]));
zfree(lp);
lpFree(lp);
}
TEST("Delete with start index out of range");
@ -2012,7 +2012,7 @@ int listpackTest(int argc, char *argv[], int flags) {
lp = createList();
lp = lpDeleteRange(lp, 5, 1);
assert(lpLength(lp) == 4);
zfree(lp);
lpFree(lp);
}
TEST("Delete with num overflow");
@ -2021,14 +2021,14 @@ int listpackTest(int argc, char *argv[], int flags) {
lp = lpDeleteRange(lp, 1, 5);
assert(lpLength(lp) == 1);
verifyEntry(lpFirst(lp), (unsigned char*)mixlist[0], strlen(mixlist[0]));
zfree(lp);
lpFree(lp);
lp = createList();
unsigned char *ptr = lpSeek(lp, 1);
lp = lpDeleteRangeWithEntry(lp, &ptr, 5);
assert(lpLength(lp) == 1);
verifyEntry(lpFirst(lp), (unsigned char*)mixlist[0], strlen(mixlist[0]));
zfree(lp);
lpFree(lp);
}
TEST("Batch delete") {
@ -2147,7 +2147,7 @@ int listpackTest(int argc, char *argv[], int flags) {
/* Merge two empty listpacks, get empty result back. */
lp1 = lpMerge(&lp1, &lp2);
assert(lpLength(lp1) == 0);
zfree(lp1);
lpFree(lp1);
}
TEST("lpMerge two listpacks - first larger than second") {
@ -2168,7 +2168,7 @@ int listpackTest(int argc, char *argv[], int flags) {
verifyEntry(lpSeek(lp3, 5), (unsigned char*)"much much longer non integer", 28);
verifyEntry(lpSeek(lp3, 6), (unsigned char*)"hello", 5);
verifyEntry(lpSeek(lp3, -1), (unsigned char*)"1024", 4);
zfree(lp3);
lpFree(lp3);
}
TEST("lpMerge two listpacks - second larger than first") {
@ -2189,7 +2189,7 @@ int listpackTest(int argc, char *argv[], int flags) {
verifyEntry(lpSeek(lp3, 3), (unsigned char*)"1024", 4);
verifyEntry(lpSeek(lp3, 4), (unsigned char*)"4294967296", 10);
verifyEntry(lpSeek(lp3, -1), (unsigned char*)"much much longer non integer", 28);
zfree(lp3);
lpFree(lp3);
}
TEST("lpNextRandom normal usage") {

View File

@ -307,9 +307,11 @@ void freeSetObject(robj *o) {
dictRelease((dict*) o->ptr);
break;
case OBJ_ENCODING_INTSET:
case OBJ_ENCODING_LISTPACK:
zfree(o->ptr);
break;
case OBJ_ENCODING_LISTPACK:
lpFree(o->ptr);
break;
default:
serverPanic("Unknown set encoding type");
}
@ -325,7 +327,7 @@ void freeZsetObject(robj *o) {
zfree(zs);
break;
case OBJ_ENCODING_LISTPACK:
zfree(o->ptr);
lpFree(o->ptr);
break;
default:
serverPanic("Unknown sorted set encoding");

View File

@ -2189,7 +2189,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
if (!lpValidateIntegrity(lp, encoded_len, deep_integrity_validation, NULL, NULL)) {
rdbReportCorruptRDB("Listpack integrity check failed.");
decrRefCount(o);
zfree(lp);
lpFree(lp);
return NULL;
}
} else {
@ -2200,7 +2200,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
rdbReportCorruptRDB("Ziplist integrity check failed.");
decrRefCount(o);
zfree(data);
zfree(lp);
lpFree(lp);
return NULL;
}
zfree(data);
@ -2209,7 +2209,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
/* Silently skip empty ziplists, if we'll end up with empty quicklist we'll fail later. */
if (lpLength(lp) == 0) {
zfree(lp);
lpFree(lp);
continue;
} else {
quicklistAppendListpack(o->ptr, lp);
@ -2369,7 +2369,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
unsigned char *lp = lpNew(encoded_len);
if (!ziplistPairsConvertAndValidateIntegrity(encoded, encoded_len, &lp)) {
rdbReportCorruptRDB("Zset ziplist integrity check failed.");
zfree(lp);
lpFree(lp);
zfree(encoded);
o->ptr = NULL;
decrRefCount(o);
@ -2415,7 +2415,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
unsigned char *lp = lpNew(encoded_len);
if (!ziplistPairsConvertAndValidateIntegrity(encoded, encoded_len, &lp)) {
rdbReportCorruptRDB("Hash ziplist integrity check failed.");
zfree(lp);
lpFree(lp);
zfree(encoded);
o->ptr = NULL;
decrRefCount(o);
@ -2507,7 +2507,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
rdbReportCorruptRDB("Stream listpack integrity check failed.");
sdsfree(nodekey);
decrRefCount(o);
zfree(lp);
lpFree(lp);
return NULL;
}
@ -2519,7 +2519,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
rdbReportCorruptRDB("Empty listpack inside stream");
sdsfree(nodekey);
decrRefCount(o);
zfree(lp);
lpFree(lp);
return NULL;
}
@ -2530,7 +2530,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
if (!retval) {
rdbReportCorruptRDB("Listpack re-added with existing key");
decrRefCount(o);
zfree(lp);
lpFree(lp);
return NULL;
}
}