diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-06-08 14:29:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-06-08 14:29:36 -0400 |
commit | 5099d858b1906bad04c531a7c98e2d0877d5e7f8 (patch) | |
tree | fee11c690ea234e175d653847baed1b9da677614 /evmap.c | |
parent | d19a3260875a85206752a2aa8eaabeefb7e854d7 (diff) | |
parent | 09fe97da3b0dcdb6ee172ff8e4f710e0baad2d1c (diff) | |
download | libevent-5099d858b1906bad04c531a7c98e2d0877d5e7f8.tar.gz |
Merge remote-tracking branch 'origin/patches-2.0'
Diffstat (limited to 'evmap.c')
-rw-r--r-- | evmap.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -128,7 +128,8 @@ HT_GENERATE(event_io_map, event_map_entry, map_node, hashsocket, eqsocket, }, \ { \ _ent = mm_calloc(1,sizeof(struct event_map_entry)+fdinfo_len); \ - EVUTIL_ASSERT(_ent); \ + if (EVUTIL_UNLIKELY(_ent == NULL)) \ + return (-1); \ _ent->fd = slot; \ (ctor)(&_ent->ent.type); \ _HT_FOI_INSERT(map_node, map, &_key, _ent, ptr) \ @@ -160,14 +161,16 @@ void evmap_io_clear(struct event_io_map *ctx) (x) = (struct type *)((map)->entries[slot]) /* As GET_SLOT, but construct the entry for 'slot' if it is not present, by allocating enough memory for a 'struct type', and initializing the new - value by calling the function 'ctor' on it. + value by calling the function 'ctor' on it. Makes the function + return -1 on allocation failure. */ #define GET_SIGNAL_SLOT_AND_CTOR(x, map, slot, type, ctor, fdinfo_len) \ do { \ if ((map)->entries[slot] == NULL) { \ (map)->entries[slot] = \ mm_calloc(1,sizeof(struct type)+fdinfo_len); \ - EVUTIL_ASSERT((map)->entries[slot] != NULL); \ + if (EVUTIL_UNLIKELY((map)->entries[slot] == NULL)) \ + return (-1); \ (ctor)((struct type *)(map)->entries[slot]); \ } \ (x) = (struct type *)((map)->entries[slot]); \ |