fix malloc macro in listpack.c (#11398)

fix some malloc macros in `listpack.c`.
listpack has it's own malloc aliases, but in some places normal redis malloc calls have slipped in.
This commit is contained in:
DarrenJiang13 2022-10-18 13:28:25 +08:00 committed by GitHub
parent a9d561afa5
commit ba1f09d3fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -1124,7 +1124,7 @@ unsigned char *lpMerge(unsigned char **first, unsigned char **second) {
lplength = lplength < UINT16_MAX ? lplength : UINT16_MAX; lplength = lplength < UINT16_MAX ? lplength : UINT16_MAX;
/* Extend target to new lpbytes then append or prepend source. */ /* Extend target to new lpbytes then append or prepend source. */
target = zrealloc(target, lpbytes); target = lp_realloc(target, lpbytes);
if (append) { if (append) {
/* append == appending to target */ /* append == appending to target */
/* Copy source after target (copying over original [END]): /* Copy source after target (copying over original [END]):
@ -1148,11 +1148,11 @@ unsigned char *lpMerge(unsigned char **first, unsigned char **second) {
/* Now free and NULL out what we didn't realloc */ /* Now free and NULL out what we didn't realloc */
if (append) { if (append) {
zfree(*second); lp_free(*second);
*second = NULL; *second = NULL;
*first = target; *first = target;
} else { } else {
zfree(*first); lp_free(*first);
*first = NULL; *first = NULL;
*second = target; *second = target;
} }
@ -1397,7 +1397,7 @@ void lpRandomPairs(unsigned char *lp, unsigned int count, listpackEntry *keys, l
unsigned int index; unsigned int index;
unsigned int order; unsigned int order;
} rand_pick; } rand_pick;
rand_pick *picks = zmalloc(sizeof(rand_pick)*count); rand_pick *picks = lp_malloc(sizeof(rand_pick)*count);
unsigned int total_size = lpLength(lp)/2; unsigned int total_size = lpLength(lp)/2;
/* Avoid div by zero on corrupt listpack */ /* Avoid div by zero on corrupt listpack */
@ -1431,7 +1431,7 @@ void lpRandomPairs(unsigned char *lp, unsigned int count, listpackEntry *keys, l
p = lpNext(lp, p); p = lpNext(lp, p);
} }
zfree(picks); lp_free(picks);
} }
/* Randomly select count of key value pairs and store into 'keys' and /* Randomly select count of key value pairs and store into 'keys' and