Skip to content

Commit

Permalink
job: Add job_delete()
Browse files Browse the repository at this point in the history
This moves freeing the Job object and its fields from block_job_unref()
to job_delete().

Signed-off-by: Kevin Wolf <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Reviewed-by: John Snow <[email protected]>
  • Loading branch information
kevmw committed May 23, 2018
1 parent 252291e commit fd61a70
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions blockjob.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
3 changes: 3 additions & 0 deletions include/qemu/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions job.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit fd61a70

Please sign in to comment.