mirror of
https://github.com/fluencelabs/redis
synced 2025-03-18 16:40:50 +00:00
Lua debugger: use sds_malloc() to allocate eval cli array.
Redis-cli handles the debugger "eval" command in a special way since sdssplitargs() would not be ok: we need to send the Redis debugger the whole Lua script without any parsing. However in order to later free the argument vector inside redis-cli using just sdsfreesplitres(), we need to allocate the array of SDS pointers using the same allocator SDS is using, that may differ to what Redis is using. So now a newer version of SDS exports sds_malloc() and other allocator functions to give access, to the program it is linked to, the allocator used internally by SDS.
This commit is contained in:
parent
34aadf79c3
commit
e57cccdefb
9
deps/hiredis/sds.c
vendored
9
deps/hiredis/sds.c
vendored
@ -1088,6 +1088,15 @@ sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen) {
|
||||
return join;
|
||||
}
|
||||
|
||||
/* Wrappers to the allocators used by SDS. Note that SDS will actually
|
||||
* just use the macros defined into sdsalloc.h in order to avoid to pay
|
||||
* the overhead of function calls. Here we define these wrappers only for
|
||||
* the programs SDS is linked to, if they want to touch the SDS internals
|
||||
* even if they use a different allocator. */
|
||||
void *sds_malloc(size_t size) { return s_malloc(size); }
|
||||
void *sds_realloc(void *ptr, size_t size) { return s_realloc(ptr,size); }
|
||||
void sds_free(void *ptr) { s_free(ptr); }
|
||||
|
||||
#if defined(SDS_TEST_MAIN)
|
||||
#include <stdio.h>
|
||||
#include "testhelp.h"
|
||||
|
8
deps/hiredis/sds.h
vendored
8
deps/hiredis/sds.h
vendored
@ -258,6 +258,14 @@ sds sdsRemoveFreeSpace(sds s);
|
||||
size_t sdsAllocSize(sds s);
|
||||
void *sdsAllocPtr(sds s);
|
||||
|
||||
/* Export the allocator used by SDS to the program using SDS.
|
||||
* Sometimes the program SDS is linked to, may use a different set of
|
||||
* allocators, but may want to allocate or free things that SDS will
|
||||
* respectively free or allocate. */
|
||||
void *sds_malloc(size_t size);
|
||||
void *sds_realloc(void *ptr, size_t size);
|
||||
void sds_free(void *ptr);
|
||||
|
||||
#ifdef REDIS_TEST
|
||||
int sdsTest(int argc, char *argv[]);
|
||||
#endif
|
||||
|
@ -1050,7 +1050,7 @@ static sds *cliSplitArgs(char *line, int *argc) {
|
||||
if (config.eval_ldb && (strstr(line,"eval ") == line ||
|
||||
strstr(line,"e ") == line))
|
||||
{
|
||||
sds *argv = zmalloc(sizeof(sds)*2);
|
||||
sds *argv = sds_malloc(sizeof(sds)*2);
|
||||
*argc = 2;
|
||||
int len = strlen(line);
|
||||
int elen = line[1] == ' ' ? 2 : 5; /* "e " or "eval "? */
|
||||
|
@ -1088,6 +1088,15 @@ sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen) {
|
||||
return join;
|
||||
}
|
||||
|
||||
/* Wrappers to the allocators used by SDS. Note that SDS will actually
|
||||
* just use the macros defined into sdsalloc.h in order to avoid to pay
|
||||
* the overhead of function calls. Here we define these wrappers only for
|
||||
* the programs SDS is linked to, if they want to touch the SDS internals
|
||||
* even if they use a different allocator. */
|
||||
void *sds_malloc(size_t size) { return s_malloc(size); }
|
||||
void *sds_realloc(void *ptr, size_t size) { return s_realloc(ptr,size); }
|
||||
void sds_free(void *ptr) { s_free(ptr); }
|
||||
|
||||
#if defined(SDS_TEST_MAIN)
|
||||
#include <stdio.h>
|
||||
#include "testhelp.h"
|
||||
|
@ -258,6 +258,14 @@ sds sdsRemoveFreeSpace(sds s);
|
||||
size_t sdsAllocSize(sds s);
|
||||
void *sdsAllocPtr(sds s);
|
||||
|
||||
/* Export the allocator used by SDS to the program using SDS.
|
||||
* Sometimes the program SDS is linked to, may use a different set of
|
||||
* allocators, but may want to allocate or free things that SDS will
|
||||
* respectively free or allocate. */
|
||||
void *sds_malloc(size_t size);
|
||||
void *sds_realloc(void *ptr, size_t size);
|
||||
void sds_free(void *ptr);
|
||||
|
||||
#ifdef REDIS_TEST
|
||||
int sdsTest(int argc, char *argv[]);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user