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