summaryrefslogtreecommitdiff
path: root/source4/lib/events.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-23 12:17:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:08 -0500
commit6c14b0133dede38294a812be7f5f5bd5ec3d498b (patch)
tree6b60ad912d6ff06e1624580ba6e8cbeda3341d1b /source4/lib/events.c
parentfd62df64188c0f992876c72fdda8a6da5dba3090 (diff)
downloadsamba-6c14b0133dede38294a812be7f5f5bd5ec3d498b.tar.gz
samba-6c14b0133dede38294a812be7f5f5bd5ec3d498b.tar.bz2
samba-6c14b0133dede38294a812be7f5f5bd5ec3d498b.zip
r4944: every event_add_*() caller was having to call talloc_steal() to take
control of the event, so instead build that into the function. If you pass NULL as mem_ctx then it leaves it as a child of the events structure. (This used to be commit 7f981b9ed96f39027cbfd500f41e0c2be64cbb50)
Diffstat (limited to 'source4/lib/events.c')
-rw-r--r--source4/lib/events.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/source4/lib/events.c b/source4/lib/events.c
index 6f0bdb4fdd..a484295d8b 100644
--- a/source4/lib/events.c
+++ b/source4/lib/events.c
@@ -157,7 +157,8 @@ static int event_fd_destructor(void *ptr)
add a fd based event
return NULL on failure (memory allocation error)
*/
-struct fd_event *event_add_fd(struct event_context *ev, struct fd_event *e0)
+struct fd_event *event_add_fd(struct event_context *ev, struct fd_event *e0,
+ TALLOC_CTX *mem_ctx)
{
struct fd_event *e = talloc(ev->events, struct fd_event);
if (!e) return NULL;
@@ -168,6 +169,9 @@ struct fd_event *event_add_fd(struct event_context *ev, struct fd_event *e0)
ev->maxfd = e->fd;
}
talloc_set_destructor(e, event_fd_destructor);
+ if (mem_ctx) {
+ talloc_steal(mem_ctx, e);
+ }
return e;
}
@@ -226,7 +230,8 @@ static int event_timed_destructor(void *ptr)
add a timed event
return NULL on failure (memory allocation error)
*/
-struct timed_event *event_add_timed(struct event_context *ev, struct timed_event *e0)
+struct timed_event *event_add_timed(struct event_context *ev, struct timed_event *e0,
+ TALLOC_CTX *mem_ctx)
{
struct timed_event *e = talloc(ev->events, struct timed_event);
if (!e) return NULL;
@@ -234,6 +239,9 @@ struct timed_event *event_add_timed(struct event_context *ev, struct timed_event
e->event_ctx = ev;
DLIST_ADD(ev->timed_events, e);
talloc_set_destructor(e, event_timed_destructor);
+ if (mem_ctx) {
+ talloc_steal(mem_ctx, e);
+ }
return e;
}
@@ -259,7 +267,8 @@ static int event_loop_destructor(void *ptr)
add a loop event
return NULL on failure (memory allocation error)
*/
-struct loop_event *event_add_loop(struct event_context *ev, struct loop_event *e0)
+struct loop_event *event_add_loop(struct event_context *ev, struct loop_event *e0,
+ TALLOC_CTX *mem_ctx)
{
struct loop_event *e = talloc(ev->events, struct loop_event);
if (!e) return NULL;
@@ -267,6 +276,9 @@ struct loop_event *event_add_loop(struct event_context *ev, struct loop_event *e
e->event_ctx = ev;
DLIST_ADD(ev->loop_events, e);
talloc_set_destructor(e, event_loop_destructor);
+ if (mem_ctx) {
+ talloc_steal(mem_ctx, e);
+ }
return e;
}