Remove unnecessary prints, clang-format
This commit is contained in:
parent
21752fb504
commit
c1b914cb8e
2 changed files with 2 additions and 13 deletions
|
@ -23,13 +23,10 @@
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **argv) {
|
||||||
simple_archiver_print_usage();
|
simple_archiver_print_usage();
|
||||||
|
|
||||||
//__attribute__((cleanup(simple_archiver_free_parsed)))
|
__attribute__((cleanup(simple_archiver_free_parsed)))
|
||||||
SDArchiverParsed parsed = simple_archiver_create_parsed();
|
SDArchiverParsed parsed = simple_archiver_create_parsed();
|
||||||
|
|
||||||
simple_archiver_parse_args(argc, argv, &parsed);
|
simple_archiver_parse_args(argc, argv, &parsed);
|
||||||
|
|
||||||
puts("freeing");
|
|
||||||
simple_archiver_free_parsed(&parsed);
|
|
||||||
puts("end");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
10
src/parser.c
10
src/parser.c
|
@ -98,25 +98,22 @@ int simple_archiver_parse_args(int argc, const char **argv,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (out->working_files == NULL) {
|
if (out->working_files == NULL) {
|
||||||
puts("first addition to working_files");
|
|
||||||
out->working_files = malloc(sizeof(char *) * 2);
|
out->working_files = malloc(sizeof(char *) * 2);
|
||||||
int arg_length = strlen(argv[0]) + 1;
|
int arg_length = strlen(argv[0]) + 1;
|
||||||
out->working_files[0] = malloc(arg_length);
|
out->working_files[0] = malloc(arg_length);
|
||||||
strncpy(out->working_files[0], argv[0], arg_length);
|
strncpy(out->working_files[0], argv[0], arg_length);
|
||||||
out->working_files[1] = NULL;
|
out->working_files[1] = NULL;
|
||||||
} else {
|
} else {
|
||||||
puts("later addition to working_files");
|
|
||||||
int working_size = 1;
|
int working_size = 1;
|
||||||
char **ptr = out->working_files;
|
char **ptr = out->working_files;
|
||||||
while (ptr && *ptr) {
|
while (ptr && *ptr) {
|
||||||
++working_size;
|
++working_size;
|
||||||
++ptr;
|
++ptr;
|
||||||
}
|
}
|
||||||
printf("working_size is %u\n", working_size);
|
|
||||||
|
|
||||||
// TODO verify this is necessary, using different variables.
|
// TODO verify this is necessary, using different variables.
|
||||||
ptr = out->working_files;
|
ptr = out->working_files;
|
||||||
out->working_files = realloc(ptr, sizeof(char*) * (working_size + 1));
|
out->working_files = realloc(ptr, sizeof(char *) * (working_size + 1));
|
||||||
|
|
||||||
// Set new actual last element to NULL.
|
// Set new actual last element to NULL.
|
||||||
out->working_files[working_size] = NULL;
|
out->working_files[working_size] = NULL;
|
||||||
|
@ -151,16 +148,11 @@ void simple_archiver_free_parsed(SDArchiverParsed *parsed) {
|
||||||
if (parsed->working_files) {
|
if (parsed->working_files) {
|
||||||
char **ptr = parsed->working_files;
|
char **ptr = parsed->working_files;
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
puts("freeing working_files strings...");
|
|
||||||
while (ptr[idx]) {
|
while (ptr[idx]) {
|
||||||
printf("Freeing at idx %u\n", idx);
|
|
||||||
free(ptr[idx]);
|
free(ptr[idx]);
|
||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
puts("freeing string array...");
|
|
||||||
free(parsed->working_files);
|
free(parsed->working_files);
|
||||||
parsed->working_files = NULL;
|
parsed->working_files = NULL;
|
||||||
|
|
||||||
puts("free_parsed is done.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue