aboutsummaryrefslogtreecommitdiffstats
path: root/src/ck.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-04-29 21:36:52 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-04-29 21:36:52 +0300
commit93eae1c206796d76e930c0c4860e4ead9c8fca14 (patch)
tree239940d27be834bcd16b28d6fcd03db4a00f3072 /src/ck.c
parent25ccc84ac00a7b3975dfdb0cc415522ca7793f0f (diff)
downloadck-93eae1c206796d76e930c0c4860e4ead9c8fca14.tar.gz
ck-93eae1c206796d76e930c0c4860e4ead9c8fca14.tar.bz2
ck-93eae1c206796d76e930c0c4860e4ead9c8fca14.zip
linkin park
Diffstat (limited to 'src/ck.c')
-rw-r--r--src/ck.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/ck.c b/src/ck.c
index a63eb63..ef499a9 100644
--- a/src/ck.c
+++ b/src/ck.c
@@ -32,30 +32,39 @@
#include "dblayer.h"
#include "ckutil.h"
+void free_res(UserOpt *opt, Conf *conf) {
+ if (opt) {
+ free_user_opt(opt);
+ }
+ if (conf) {
+ free_conf(conf);
+ }
+}
+
int main(int argc, char *argv[]) {
UserOpt opt;
switch(parse_action(argc, argv, &opt)) {
case APR_HELP:
- free_user_opt(&opt);
+ free_res(&opt, NULL);
print_parser_help();
return 0;
case APR_ERR:
print_parser_error(&opt);
- free_user_opt(&opt);
+ free_res(&opt, NULL);
return 1;
case APR_OK:
break;
}
- Conf conf;
+ Conf conf = {.VC_dir = NULL, .SCRT_dir = NULL};
if (opt.action != CKA_INIT) {
if (!db_exists(&opt)) {
printf("ck is not initialized in %s.\nRun ck init first.\n", opt.confDir);
- free_user_opt(&opt);
+ free_res(&opt, NULL);
return 1;
}
if (!config_file_parse(&conf, &opt)) {
- free_user_opt(&opt);
+ free_res(&opt, &conf);
return 1;
}
}
@@ -71,6 +80,6 @@ int main(int argc, char *argv[]) {
default:
break;
}
- free_user_opt(&opt);
+ free_res(&opt, &conf);
return 0;
}