mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-14 14:54:49 -04:00
Remove some duplicate code in kqueue.c and fix a small memory leak.
svn:r1483
This commit is contained in:
parent
96c6956e02
commit
315fde1a70
25
kqueue.c
25
kqueue.c
@ -79,6 +79,8 @@ struct kqop {
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void kqop_free(struct kqop *kqop);
|
||||||
|
|
||||||
static void *kq_init (struct event_base *);
|
static void *kq_init (struct event_base *);
|
||||||
static int kq_add (struct event_base *, int, short, short, void *);
|
static int kq_add (struct event_base *, int, short, short, void *);
|
||||||
static int kq_del (struct event_base *, int, short, short, void *);
|
static int kq_del (struct event_base *, int, short, short, void *);
|
||||||
@ -167,13 +169,9 @@ kq_init(struct event_base *base)
|
|||||||
|
|
||||||
return (kqueueop);
|
return (kqueueop);
|
||||||
err:
|
err:
|
||||||
if (kqueueop->changes)
|
if (kqueueop)
|
||||||
mm_free(kqueueop->changes);
|
kqop_free(kqueueop);
|
||||||
if (kqueueop->pend_changes)
|
|
||||||
mm_free(kqueueop->pend_changes);
|
|
||||||
if (kq >= 0)
|
|
||||||
close(kq);
|
|
||||||
mm_free(kqueueop);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,12 +388,12 @@ kq_del(struct event_base *base, int fd, short old, short events, void *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
kq_dealloc(struct event_base *base)
|
kqop_free(struct kqop *kqop)
|
||||||
{
|
{
|
||||||
struct kqop *kqop = base->evbase;
|
|
||||||
|
|
||||||
if (kqop->changes)
|
if (kqop->changes)
|
||||||
mm_free(kqop->changes);
|
mm_free(kqop->changes);
|
||||||
|
if (kqop->pend_changes)
|
||||||
|
mm_free(kqop->pend_changes);
|
||||||
if (kqop->events)
|
if (kqop->events)
|
||||||
mm_free(kqop->events);
|
mm_free(kqop->events);
|
||||||
if (kqop->kq >= 0 && kqop->pid == getpid())
|
if (kqop->kq >= 0 && kqop->pid == getpid())
|
||||||
@ -404,6 +402,13 @@ kq_dealloc(struct event_base *base)
|
|||||||
mm_free(kqop);
|
mm_free(kqop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
kq_dealloc(struct event_base *base)
|
||||||
|
{
|
||||||
|
struct kqop *kqop = base->evbase;
|
||||||
|
kqop_free(kqop);
|
||||||
|
}
|
||||||
|
|
||||||
/* signal handling */
|
/* signal handling */
|
||||||
static int
|
static int
|
||||||
kq_sig_add(struct event_base *base, int nsignal, short old, short events, void *p)
|
kq_sig_add(struct event_base *base, int nsignal, short old, short events, void *p)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user