mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Prefer calloc(a,b) to malloc(a*b). via openbsd.
svn:r1531
This commit is contained in:
parent
629a613398
commit
18a8cfac39
2
epoll.c
2
epoll.c
@ -117,7 +117,7 @@ epoll_init(struct event_base *base)
|
||||
epollop->epfd = epfd;
|
||||
|
||||
/* Initialize fields */
|
||||
epollop->events = mm_malloc(INITIAL_NEVENT * sizeof(struct epoll_event));
|
||||
epollop->events = mm_calloc(INITIAL_NEVENT, sizeof(struct epoll_event));
|
||||
if (epollop->events == NULL) {
|
||||
mm_free(epollop);
|
||||
return (NULL);
|
||||
|
6
evdns.c
6
evdns.c
@ -1110,7 +1110,7 @@ request_parse(u8 *packet, int length, struct evdns_server_port *port, struct soc
|
||||
|
||||
server_req->base.flags = flags;
|
||||
server_req->base.nquestions = 0;
|
||||
server_req->base.questions = mm_malloc(sizeof(struct evdns_server_question *) * questions);
|
||||
server_req->base.questions = mm_calloc(sizeof(struct evdns_server_question *), questions);
|
||||
if (server_req->base.questions == NULL)
|
||||
goto err;
|
||||
|
||||
@ -3143,11 +3143,9 @@ evdns_base_set_max_requests_inflight(struct evdns_base *base, int maxinflight)
|
||||
maxinflight = 1;
|
||||
n_heads = (maxinflight+4) / 5;
|
||||
EVUTIL_ASSERT(n_heads > 0);
|
||||
new_heads = mm_malloc(n_heads * sizeof(struct evdns_request*));
|
||||
new_heads = mm_calloc(n_heads, sizeof(struct evdns_request*));
|
||||
if (!new_heads)
|
||||
return (-1);
|
||||
for (i=0; i < n_heads; ++i)
|
||||
new_heads[i] = NULL;
|
||||
if (old_heads) {
|
||||
for (i = 0; i < old_n_heads; ++i) {
|
||||
while (old_heads[i]) {
|
||||
|
2
event.c
2
event.c
@ -539,7 +539,7 @@ event_get_supported_methods(void)
|
||||
}
|
||||
|
||||
/* allocate one more than we need for the NULL pointer */
|
||||
tmp = mm_malloc((i + 1) * sizeof(char *));
|
||||
tmp = mm_calloc((i + 1), sizeof(char *));
|
||||
if (tmp == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
6
kqueue.c
6
kqueue.c
@ -133,13 +133,13 @@ kq_init(struct event_base *base)
|
||||
kqueueop->pid = getpid();
|
||||
|
||||
/* Initialize fields */
|
||||
kqueueop->changes = mm_malloc(NEVENT * sizeof(struct kevent));
|
||||
kqueueop->changes = mm_calloc(NEVENT, sizeof(struct kevent));
|
||||
if (kqueueop->changes == NULL)
|
||||
goto err;
|
||||
kqueueop->pend_changes = mm_malloc(NEVENT * sizeof(struct kevent));
|
||||
kqueueop->pend_changes = mm_calloc(NEVENT, sizeof(struct kevent));
|
||||
if (kqueueop->pend_changes == NULL)
|
||||
goto err;
|
||||
kqueueop->events = mm_malloc(NEVENT * sizeof(struct kevent));
|
||||
kqueueop->events = mm_calloc(NEVENT, sizeof(struct kevent));
|
||||
if (kqueueop->events == NULL)
|
||||
goto err;
|
||||
kqueueop->events_size = kqueueop->changes_size =
|
||||
|
Loading…
x
Reference in New Issue
Block a user