diff options
author | jozan <jozan@noemail.net> | 2020-11-06 01:46:51 +0000 |
---|---|---|
committer | jozan <jozan@noemail.net> | 2020-11-06 01:46:51 +0000 |
commit | 412fdac1d09dc208c244e3a94002b29b4cf6c6db (patch) | |
tree | 79900a722b811a643ba11872957cc51744e44292 | |
parent | Recursion in progress (diff) | |
download | unixize-412fdac1d09dc208c244e3a94002b29b4cf6c6db.tar.gz unixize-412fdac1d09dc208c244e3a94002b29b4cf6c6db.tar.bz2 unixize-412fdac1d09dc208c244e3a94002b29b4cf6c6db.tar.xz unixize-412fdac1d09dc208c244e3a94002b29b4cf6c6db.tar.zst unixize-412fdac1d09dc208c244e3a94002b29b4cf6c6db.zip |
Freed some leaks, work in progress
FossilOrigin-Name: b064861e053bf920fc0a33d1e03900d023d0ca123c96e279abd58f5e78661a34
-rw-r--r-- | src/c_opts.c | 6 | ||||
-rw-r--r-- | src/c_unixize.c | 4 | ||||
-rw-r--r-- | src/u_utils.c | 15 |
3 files changed, 13 insertions, 12 deletions
diff --git a/src/c_opts.c b/src/c_opts.c index c4efa73..2c73288 100644 --- a/src/c_opts.c +++ b/src/c_opts.c @@ -69,14 +69,14 @@ c_ask_confirm(const char dir[]) char c; if (strncmp(dir, ".", 2 * sizeof(char)) == 0) { - printf("unixize current directory? (y/n [n]) "); + dprintf(STDERR_FILENO, "unixize current directory? (y/n [n]) "); } else { - printf("unixize %s? (y/n [n]) ", dir); + dprintf(STDERR_FILENO, "unixize %s? (y/n [n]) ", dir); } scanf("%c", &c); if (c != 'y' && c != 'Y') { - printf("not unixized\n"); + dprintf(STDERR_FILENO, "not unixized\n"); exit(0); } } diff --git a/src/c_unixize.c b/src/c_unixize.c index bbf75f6..45ce8d5 100644 --- a/src/c_unixize.c +++ b/src/c_unixize.c @@ -62,11 +62,11 @@ main (int argc, const char* argv[]) { - struct opts_s opts; struct lfiles_s* og_files; struct lfiles_s* new_files; struct lfiles_s* og_files_head; struct lfiles_s* new_files_head; + struct opts_s opts; int nargc; char** nargv; @@ -109,7 +109,7 @@ main chdir("../"); } } - printf("'%s' -> '%s'\n", og_files->filename, new_files->filename); + /* printf("'%s' -> '%s'\n", og_files->filename, new_files->filename); */ /* rename(); */ og_files = og_files->next; new_files = new_files->next; diff --git a/src/u_utils.c b/src/u_utils.c index 000cbca..4af6579 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -107,7 +107,7 @@ u_get_extra_args(char args[], struct opts_s* opts) i++; } if (i > 0) { - *(args + ((i - 2) * 3) - 1) = 0x00; + *(args + (i * 3) - 1) = 0x00; } return (i); } @@ -119,8 +119,10 @@ u_del_nargv(char** nargv) ptr = nargv; while (*ptr != NULL) { + u_memdel((void*)&nargv[ptr - nargv]); ptr++; } + u_memdel((void*)&nargv); } char** @@ -151,17 +153,17 @@ u_get_nargv(struct opts_s* opts) return (NULL); } if (i > 2) { - i = 2; tok = strtok(args, ":"); - nargv[i] = strdup(tok); - if (nargv[i] == NULL) { + nargv[3] = strdup(tok); + if (nargv[3] == NULL) { u_del_nargv(nargv); return (NULL); } - nargv[i + 1] = NULL; + nargv[4] = NULL; + i = 4; while ((tok = strtok(NULL, ":")) != NULL) { nargv[i] = strdup(tok); - if (nargv[i] == NULL) { + if (nargv[i] != NULL) { u_del_nargv(nargv); return (NULL); } @@ -169,6 +171,5 @@ u_get_nargv(struct opts_s* opts) i++; } } - exit(0); return (nargv); } |