}
viewport = calloc(1, sizeof *viewport);
- if (!viewport) {
- wl_resource_post_no_memory(resource);
- return;
- }
+ if (!viewport)
+ goto err_alloc;
viewport->resource = wl_resource_create(client, &wl_viewport_interface,
wl_resource_get_version(resource), id);
- if (!viewport->resource) {
- wl_resource_post_no_memory(resource);
- free(viewport);
- return;
- }
+ if (!viewport->resource)
+ goto err_resource;
+
wl_resource_set_implementation(viewport->resource, &viewport_iface,
viewport, viewport_handle_resource_destroy);
viewport->surface_commit.notify = viewport_handle_surface_commit;
ds_surface_add_commit_listener(surface, &viewport->surface_commit);
+
+ return;
+err_resource:
+ wl_resource_post_no_memory(resource);
+ free(viewport);
+err_alloc:
+ ds_surface_viewport_release(surface_viewport);
}
static const struct wl_scaler_interface scaler_iface = {