Added two assertions
This commit is contained in:
parent
ae18ccfcb7
commit
9c3ebc73dd
11
src/event.c
11
src/event.c
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -252,8 +253,9 @@ int event_register_io_read(Event * event, int fd, EventIOFunc func,
|
||||||
{
|
{
|
||||||
EventIO * eventio;
|
EventIO * eventio;
|
||||||
|
|
||||||
if((eventio = malloc(sizeof(EventIO))) == NULL)
|
assert(fd >= 0);
|
||||||
return 1;
|
if((eventio = malloc(sizeof(*eventio))) == NULL)
|
||||||
|
return error_set_code(1, "%s", strerror(errno));
|
||||||
eventio->fd = fd;
|
eventio->fd = fd;
|
||||||
eventio->func = func;
|
eventio->func = func;
|
||||||
eventio->data = userdata;
|
eventio->data = userdata;
|
||||||
|
@ -270,8 +272,9 @@ int event_register_io_write(Event * event, int fd, EventIOFunc func,
|
||||||
{
|
{
|
||||||
EventIO * eventio;
|
EventIO * eventio;
|
||||||
|
|
||||||
if((eventio = malloc(sizeof(EventIO))) == NULL)
|
assert(fd >= 0);
|
||||||
return 1;
|
if((eventio = malloc(sizeof(*eventio))) == NULL)
|
||||||
|
return error_set_code(1, "%s", strerror(errno));
|
||||||
eventio->fd = fd;
|
eventio->fd = fd;
|
||||||
eventio->func = func;
|
eventio->func = func;
|
||||||
eventio->data = userdata;
|
eventio->data = userdata;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user