c/main: Normalize destroy pattern for comp_renderer.

This commit is contained in:
Ryan Pavlik 2021-04-15 13:43:02 -05:00 committed by Jakob Bornecrantz
parent 70982e9c39
commit 7c2ea1369f
3 changed files with 13 additions and 6 deletions

View file

@ -552,10 +552,7 @@ compositor_destroy(struct xrt_compositor *xc)
// Make sure we don't have anything to destroy.
comp_compositor_garbage_collect(c);
if (c->r) {
comp_renderer_destroy(c->r);
c->r = NULL;
}
comp_renderer_destroy(&c->r);
comp_resources_close(c, &c->nr);

View file

@ -120,10 +120,18 @@ comp_renderer_create(struct comp_compositor *c)
}
void
comp_renderer_destroy(struct comp_renderer *r)
comp_renderer_destroy(struct comp_renderer **ptr_r)
{
if (ptr_r == NULL) {
return;
}
struct comp_renderer *r = *ptr_r;
if (r == NULL) {
return;
}
renderer_destroy(r);
free(r);
*ptr_r = NULL;
}
/*

View file

@ -38,11 +38,13 @@ comp_renderer_create(struct comp_compositor *c);
/*!
* Clean up and free the renderer.
*
* Does null checking and sets to null after freeing.
*
* @public @memberof comp_renderer
* @ingroup comp_main
*/
void
comp_renderer_destroy(struct comp_renderer *r);
comp_renderer_destroy(struct comp_renderer **ptr_r);
/*!
* Render frame.