Add missing cleanup
[platform/core/uifw/libds-tizen.git] / src / libds / allocator.c
1 #include <assert.h>
2 #include <stdlib.h>
3 #include <wayland-server.h>
4
5 #include "libds/log.h"
6 #include "libds/interfaces/allocator.h"
7
8 WL_EXPORT void
9 ds_allocator_init(struct ds_allocator *alloc,
10         const struct ds_allocator_interface *iface, uint32_t buffer_caps)
11 {
12     alloc->iface = iface;
13     alloc->buffer_caps = buffer_caps;
14
15     wl_signal_init(&alloc->events.destroy);
16 }
17
18 WL_EXPORT void
19 ds_allocator_destroy(struct ds_allocator *alloc)
20 {
21     wl_signal_emit(&alloc->events.destroy, NULL);
22     alloc->iface->destroy(alloc);
23 }
24
25 WL_EXPORT struct ds_buffer *
26 ds_allocator_create_buffer(struct ds_allocator *alloc, int width, int height,
27         uint32_t format)
28 {
29     return alloc->iface->create_buffer(alloc, width, height, format);
30 }
31
32 WL_EXPORT void
33 ds_allocator_add_destroy_listener(struct ds_allocator *alloc,
34         struct wl_listener *listener)
35 {
36     wl_signal_add(&alloc->events.destroy, listener);
37 }