aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-06-10 20:22:22 +0530
committersinanmohd <sinan@sinanmohd.com>2024-06-10 20:23:43 +0530
commitd69cf8e89b3d7e182d2ef55a8f9b5e90b38fac5b (patch)
tree16d35ab26afe254ad14666ea114dd39632c86457
parent8dfff0655a2f93cc540bbaf7b88fb820431ecd02 (diff)
src/jobs: clean up
-rw-r--r--include/jobs.h2
-rw-r--r--src/jobs.c15
2 files changed, 11 insertions, 6 deletions
diff --git a/include/jobs.h b/include/jobs.h
index 571be0d..41bfa57 100644
--- a/include/jobs.h
+++ b/include/jobs.h
@@ -9,7 +9,7 @@ struct output {
LIST_HEAD(job_dlist, job);
struct job {
- char *drv_path, *name;
+ char *name, *drv_path;
struct output_dlist outputs;
struct job_dlist deps;
diff --git a/src/jobs.c b/src/jobs.c
index 7893632..78b52cc 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -9,12 +9,13 @@
#include "util.h"
static int job_output_insert(struct job *j, char *name, char *store_path);
+static void output_free(struct output *output);
int job_read(FILE *stream, struct job **job)
{
int ret;
- cJSON *root, *temp, *input_drvs, *array;
struct job *dep_job;
+ cJSON *root, *temp, *input_drvs, *array;
char *name = NULL;
char *out_name = NULL;
char *drv_path = NULL;
@@ -82,8 +83,9 @@ int job_read(FILE *stream, struct job **job)
}
}
- LIST_INSERT_HEAD(&(*job)->deps, dep_job, dlist);
drv_path = NULL;
+ out_name = NULL;
+ LIST_INSERT_HEAD(&(*job)->deps, dep_job, dlist);
}
out_free:
@@ -93,11 +95,12 @@ out_free:
print_err("%s", "Invalid JSON");
free(name);
free(drv_path);
+ free(out_name);
}
return ret;
}
-void output_free(struct output *output)
+static void output_free(struct output *output)
{
if (output == NULL)
return;
@@ -118,12 +121,14 @@ void job_free(struct job *job)
free(job->name);
free(job->drv_path);
- free(job);
+
LIST_FOREACH (o, &job->outputs, dlist)
output_free(o);
LIST_FOREACH (j, &job->deps, dlist)
job_free(j);
+
+ free(job);
}
static int job_output_insert(struct job *j, char *name, char *store_path)
@@ -148,7 +153,7 @@ int job_new(struct job **j, char *name, char *drv_path)
struct job *job;
job = malloc(sizeof(*job));
- if (*j == NULL) {
+ if (job == NULL) {
print_err("%s", strerror(errno));
return -errno;
}