mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2024-12-27 21:59:24 +01:00
Allow NULL to be passed to destructors
In this case, the destructor will be a no-op. This is similar to free(3)'s behavior and allows to omit a NULL check for callers.
This commit is contained in:
parent
7286146341
commit
cfeee41ec1
3 changed files with 12 additions and 0 deletions
4
device.c
4
device.c
|
@ -70,6 +70,10 @@ void liftoff_device_destroy(struct liftoff_device *device)
|
||||||
{
|
{
|
||||||
struct liftoff_plane *plane, *tmp;
|
struct liftoff_plane *plane, *tmp;
|
||||||
|
|
||||||
|
if (device == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
close(device->drm_fd);
|
close(device->drm_fd);
|
||||||
liftoff_list_for_each_safe(plane, tmp, &device->planes, link) {
|
liftoff_list_for_each_safe(plane, tmp, &device->planes, link) {
|
||||||
plane_destroy(plane);
|
plane_destroy(plane);
|
||||||
|
|
4
layer.c
4
layer.c
|
@ -19,6 +19,10 @@ struct liftoff_layer *liftoff_layer_create(struct liftoff_output *output)
|
||||||
|
|
||||||
void liftoff_layer_destroy(struct liftoff_layer *layer)
|
void liftoff_layer_destroy(struct liftoff_layer *layer)
|
||||||
{
|
{
|
||||||
|
if (layer == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
layer->output->layers_changed = true;
|
layer->output->layers_changed = true;
|
||||||
if (layer->plane != NULL) {
|
if (layer->plane != NULL) {
|
||||||
layer->plane->layer = NULL;
|
layer->plane->layer = NULL;
|
||||||
|
|
4
output.c
4
output.c
|
@ -37,6 +37,10 @@ struct liftoff_output *liftoff_output_create(struct liftoff_device *device,
|
||||||
|
|
||||||
void liftoff_output_destroy(struct liftoff_output *output)
|
void liftoff_output_destroy(struct liftoff_output *output)
|
||||||
{
|
{
|
||||||
|
if (output == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
liftoff_list_remove(&output->link);
|
liftoff_list_remove(&output->link);
|
||||||
free(output);
|
free(output);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue