Cleanup in redis-cli and tests: release memory on exit, change dup test name (#8475)

1. Rename 18-cluster-nodes-slots.tcl to 19-cluster-nodes-slots.tcl.
  it was conflicting with another test prefixed by 18
2. Release memory on exit in redis-cli.c.
3. Fix freeConvertedSds indentation.
This commit is contained in:
WuYunlong 2021-02-09 18:36:09 +08:00 committed by GitHub
parent 8f9958dc24
commit 203f357c32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View File

@ -1929,13 +1929,20 @@ static int confirmWithYes(char *msg, int ignore_force) {
/* Turn the plain C strings into Sds strings */
static char **convertToSds(int count, char** args) {
int j;
char **sds = zmalloc(sizeof(char*)*count);
int j;
char **sds = zmalloc(sizeof(char*)*count);
for(j = 0; j < count; j++)
sds[j] = sdsnew(args[j]);
for(j = 0; j < count; j++)
sds[j] = sdsnew(args[j]);
return sds;
return sds;
}
static void freeConvertedSds(int count, char **sds) {
int j;
for (j = 0; j < count; j++)
sdsfree(sds[j]);
zfree(sds);
}
static int issueCommandRepeat(int argc, char **argv, long repeat) {
@ -2168,13 +2175,17 @@ static void repl(void) {
static int noninteractive(int argc, char **argv) {
int retval = 0;
argv = convertToSds(argc, argv);
if (config.stdinarg) {
argv = zrealloc(argv, (argc+1)*sizeof(char*));
argv[argc] = readArgFromStdin();
retval = issueCommand(argc+1, argv);
sdsfree(argv[argc]);
} else {
retval = issueCommand(argc, argv);
}
freeConvertedSds(argc, argv);
return retval;
}
@ -8331,6 +8342,6 @@ int main(int argc, char **argv) {
if (config.eval) {
return evalMode(argc,argv);
} else {
return noninteractive(argc,convertToSds(argc,argv));
return noninteractive(argc,argv);
}
}