Nothing was freeing the allocation from screenshooter_create().
Add enough boilerplate, that we can free it. Fixes a Valgrind leak.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
ec->fade.animation.frame = fade_frame;
wl_list_init(&ec->fade.animation.link);
- screenshooter_create(ec);
+ ec->screenshooter = screenshooter_create(ec);
wlsc_data_device_manager_init(ec);
wl_event_source_remove(ec->idle_source);
+ if (ec->screenshooter)
+ screenshooter_destroy(ec->screenshooter);
+
/* Destroy all outputs associated with this compositor */
wl_list_for_each_safe(output, next, &ec->output_list, link)
output->destroy(output);
WLSC_COMPOSITOR_SLEEPING /* no rendering, no frame events */
};
+struct screenshooter;
+
struct wlsc_compositor {
struct wl_shm *shm;
struct wlsc_xserver *wxs;
int (*authenticate)(struct wlsc_compositor *c, uint32_t id);
EGLImageKHR (*create_cursor_image)(struct wlsc_compositor *c,
int32_t *width, int32_t *height);
+
+ struct screenshooter *screenshooter;
};
#define MODIFIER_CTRL (1 << 8)
void
tty_destroy(struct tty *tty);
-void
+struct screenshooter *
screenshooter_create(struct wlsc_compositor *ec);
+void
+screenshooter_destroy(struct screenshooter *shooter);
+
uint32_t *
wlsc_load_image(const char *filename,
int32_t *width_arg, int32_t *height_arg, uint32_t *stride_arg);
struct screenshooter {
struct wl_object base;
struct wlsc_compositor *ec;
+ struct wl_global *global;
};
static void
&screenshooter_implementation, id, data);
}
-void
+struct screenshooter *
screenshooter_create(struct wlsc_compositor *ec)
{
struct screenshooter *shooter;
shooter = malloc(sizeof *shooter);
if (shooter == NULL)
- return;
+ return NULL;
shooter->base.interface = &screenshooter_interface;
shooter->base.implementation =
(void(**)(void)) &screenshooter_implementation;
shooter->ec = ec;
- wl_display_add_global(ec->wl_display,
- &screenshooter_interface, shooter, bind_shooter);
-};
+ shooter->global = wl_display_add_global(ec->wl_display,
+ &screenshooter_interface,
+ shooter, bind_shooter);
+
+ return shooter;
+}
+
+void
+screenshooter_destroy(struct screenshooter *shooter)
+{
+ wl_display_remove_global(shooter->ec->wl_display, shooter->global);
+ free(shooter);
+}