mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
impl->destroy cleanup:
- remove trivial destroy() function - make sure we check impl and impl->destroy before calling - always call free if not implemented
This commit is contained in:
parent
ba20d5b3ca
commit
4bbf718e7d
6 changed files with 11 additions and 10 deletions
|
@ -32,8 +32,10 @@ bool wlr_backend_start(struct wlr_backend *backend) {
|
|||
}
|
||||
|
||||
void wlr_backend_destroy(struct wlr_backend *backend) {
|
||||
if (backend->impl->destroy) {
|
||||
if (backend->impl && backend->impl->destroy) {
|
||||
backend->impl->destroy(backend);
|
||||
} else {
|
||||
free(backend);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
|||
|
||||
struct wlr_wl_backend_output *output;
|
||||
if (!(output = calloc(sizeof(struct wlr_wl_backend_output), 1))) {
|
||||
wlr_log(L_ERROR, "Failed to allocate wlr_output_state");
|
||||
wlr_log(L_ERROR, "Failed to allocate wlr_wl_backend_output");
|
||||
return NULL;
|
||||
}
|
||||
wlr_output_init(&output->wlr_output, &output_impl);
|
||||
|
|
|
@ -227,10 +227,6 @@ static bool wlr_gles2_buffer_is_drm(struct wlr_renderer *_renderer,
|
|||
EGL_TEXTURE_FORMAT, &format);
|
||||
}
|
||||
|
||||
static void wlr_gles2_destroy(struct wlr_renderer *renderer) {
|
||||
free(renderer);
|
||||
}
|
||||
|
||||
static struct wlr_renderer_impl wlr_renderer_impl = {
|
||||
.begin = wlr_gles2_begin,
|
||||
.end = wlr_gles2_end,
|
||||
|
@ -240,7 +236,6 @@ static struct wlr_renderer_impl wlr_renderer_impl = {
|
|||
.render_ellipse = wlr_gles2_render_ellipse,
|
||||
.formats = wlr_gles2_formats,
|
||||
.buffer_is_drm = wlr_gles2_buffer_is_drm,
|
||||
.destroy = wlr_gles2_destroy
|
||||
};
|
||||
|
||||
struct wlr_renderer *wlr_gles2_renderer_init(struct wlr_backend *backend) {
|
||||
|
|
|
@ -8,8 +8,10 @@ void wlr_renderer_init(struct wlr_renderer *renderer,
|
|||
}
|
||||
|
||||
void wlr_renderer_destroy(struct wlr_renderer *r) {
|
||||
if (r && r->impl->destroy) {
|
||||
if (r && r->impl && r->impl->destroy) {
|
||||
r->impl->destroy(r);
|
||||
} else {
|
||||
free(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,10 @@ void wlr_texture_init(struct wlr_texture *texture,
|
|||
}
|
||||
|
||||
void wlr_texture_destroy(struct wlr_texture *texture) {
|
||||
if (texture && texture->impl->destroy) {
|
||||
if (texture && texture->impl && texture->impl->destroy) {
|
||||
texture->impl->destroy(texture);
|
||||
} else {
|
||||
free(texture);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ void wlr_output_destroy(struct wlr_output *output) {
|
|||
free(mode);
|
||||
}
|
||||
list_free(output->modes);
|
||||
if (output->impl->destroy) {
|
||||
if (output->impl && output->impl->destroy) {
|
||||
output->impl->destroy(output);
|
||||
} else {
|
||||
free(output);
|
||||
|
|
Loading…
Reference in a new issue