]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
job: Add job_delete()
authorKevin Wolf <kwolf@redhat.com>
Thu, 12 Apr 2018 17:06:53 +0000 (19:06 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 23 May 2018 12:30:49 +0000 (14:30 +0200)
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>
blockjob.c
include/qemu/job.h
job.c

index ea71ec0129899a577854a71d82b84f2f06c423a6..430a67ba63891d4fc2acbeea3c34794def1fa0c0 100644 (file)
@@ -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);
     }
 }
 
index 279ce688fda2f9adef77596d2c676249b3e6eb88..43dc2e4a7d3f684af20fad996a4b2f6e30ee48ea 100644 (file)
@@ -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/job.c b/job.c
index 83724a43debb04a17ab25a07ea78b27c04385690..cfdd008c52dde30aee83cb029614874aec76c3cf 100644 (file)
--- a/job.c
+++ b/job.c
@@ -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);
+}