This moves freeing the Job object and its fields from block_job_unref()
to job_delete().
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
include/qemu/job.h | 3 +++
blockjob.c | 3 +--
job.c | 6 ++++++
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/qemu/job.h b/include/qemu/job.h
index 279ce688fd..43dc2e4a7d 100644
@@ -62,6 +62,9 @@ struct JobDriver {
*/
void *job_create(const char *job_id, const JobDriver *driver, Error **errp);
+/** Frees the @job object. */
+void job_delete(Job *job);
+
/** Returns the JobType of a given Job. */
JobType job_type(const Job *job);
diff --git a/blockjob.c b/blockjob.c
index ea71ec0129..430a67ba63 100644
@@ -261,9 +261,8 @@ void block_job_unref(BlockJob *job)
block_job_detach_aio_context, job);
blk_unref(job->blk);
error_free(job->blocker);
- g_free(job->job.id);
assert(!timer_pending(&job->sleep_timer));
- g_free(job);
+ job_delete(&job->job);
}
}
diff --git a/job.c b/job.c
index 83724a43de..cfdd008c52 100644
@@ -56,3 +56,9 @@ void *job_create(const char *job_id, const JobDriver *driver, Error **errp)
return job;
}
+
+void job_delete(Job *job)
+{
+ g_free(job->id);
+ g_free(job);
+}
--
2.13.6