Browse Source

MT#56374 use slice allocator in poller

Change-Id: Id51767c2006273045f7d1870ad162650a075131e
pull/1701/head
Richard Fuchs 2 years ago
parent
commit
386f1d91bf
1 changed files with 4 additions and 6 deletions
  1. +4
    -6
      lib/poller.c

+ 4
- 6
lib/poller.c View File

@ -44,8 +44,7 @@ struct poller_map {
struct poller_map *poller_map_new(void) { struct poller_map *poller_map_new(void) {
struct poller_map *p; struct poller_map *p;
p = malloc(sizeof(*p));
memset(p, 0, sizeof(*p));
p = g_slice_alloc0(sizeof(*p));
mutex_init(&p->lock); mutex_init(&p->lock);
p->table = g_hash_table_new(g_direct_hash, g_direct_equal); p->table = g_hash_table_new(g_direct_hash, g_direct_equal);
@ -96,15 +95,14 @@ void poller_map_free(struct poller_map **map) {
g_hash_table_destroy(m->table); g_hash_table_destroy(m->table);
mutex_unlock(&m->lock); mutex_unlock(&m->lock);
mutex_destroy(&m->lock); mutex_destroy(&m->lock);
free(m);
g_slice_free1(sizeof(*m), m);
*map = NULL; *map = NULL;
} }
struct poller *poller_new(void) { struct poller *poller_new(void) {
struct poller *p; struct poller *p;
p = malloc(sizeof(*p));
memset(p, 0, sizeof(*p));
p = g_slice_alloc0(sizeof(*p));
gettimeofday(&rtpe_now, NULL); gettimeofday(&rtpe_now, NULL);
p->fd = epoll_create1(0); p->fd = epoll_create1(0);
if (p->fd == -1) if (p->fd == -1)
@ -128,7 +126,7 @@ void poller_free(struct poller **pp) {
p->fd = -1; p->fd = -1;
if (p->items) if (p->items)
free(p->items); free(p->items);
free(p);
g_slice_free1(sizeof(*p), p);
*pp = NULL; *pp = NULL;
} }


Loading…
Cancel
Save