Message ID | 20180509162637.15575-12-kwolf@redhat.com |
---|---|
State | New |
Headers | show |
Series | Generic background jobs | expand |
On 2018-05-09 18:26, Kevin Wolf wrote: > This moves freeing the Job object and its fields from block_job_unref() > to job_delete(). > > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > include/qemu/job.h | 3 +++ > blockjob.c | 3 +-- > job.c | 6 ++++++ > 3 files changed, 10 insertions(+), 2 deletions(-) Reviewed-by: Max Reitz <mreitz@redhat.com>
On 05/09/2018 12:26 PM, Kevin Wolf wrote: > 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: John Snow <jsnow@redhat.com> I guess the reference counting comes later. *peeks* Oh, soon!
On 05/09/2018 11:26 AM, Kevin Wolf wrote: > This moves freeing the Job object and its fields from block_job_unref() > to job_delete(). > > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > include/qemu/job.h | 3 +++ > blockjob.c | 3 +-- > job.c | 6 ++++++ > 3 files changed, 10 insertions(+), 2 deletions(-) > > + > +void job_delete(Job *job) > +{ > + g_free(job->id); > + g_free(job); > +} Should this be free-like, acting as a no-op when job == NULL on input?
diff --git a/include/qemu/job.h b/include/qemu/job.h index c87e951c8a..ee1f5d1ef4 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -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(Job *job); diff --git a/blockjob.c b/blockjob.c index 3cf28eb730..f1bff2272e 100644 --- a/blockjob.c +++ b/blockjob.c @@ -247,9 +247,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 f00f401502..a36425498d 100644 --- 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); +}
This moves freeing the Job object and its fields from block_job_unref() to job_delete(). Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- include/qemu/job.h | 3 +++ blockjob.c | 3 +-- job.c | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-)