diff options
author | Stefan Metzmacher <metze@samba.org> | 2009-01-02 12:06:39 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2009-01-02 18:16:48 +0100 |
commit | 3f8f99eaecf7a07126969594c41c00392b85cefd (patch) | |
tree | 9860cf8dfa472c6d2c23e4e407d1457f8e903f7a /source4/lib | |
parent | 54c0f626f51c33245ae8f7778cc6ad6b48ae0f93 (diff) | |
download | samba-3f8f99eaecf7a07126969594c41c00392b85cefd.tar.gz samba-3f8f99eaecf7a07126969594c41c00392b85cefd.tar.bz2 samba-3f8f99eaecf7a07126969594c41c00392b85cefd.zip |
s4:tevent: move event_context_find() to tevent_s4.c
metze
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/events/tevent_s4.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source4/lib/events/tevent_s4.c b/source4/lib/events/tevent_s4.c index b3de7e667a..e50ff57e90 100644 --- a/source4/lib/events/tevent_s4.c +++ b/source4/lib/events/tevent_s4.c @@ -70,3 +70,20 @@ struct tevent_context *s4_event_context_init(TALLOC_CTX *mem_ctx) return ev; } +/* + find an event context that is a parent of the given memory context, + or create a new event context as a child of the given context if + none is found + + This should be used in preference to event_context_init() in places + where you would prefer to use the existing event context if possible + (which is most situations) +*/ +struct tevent_context *event_context_find(TALLOC_CTX *mem_ctx) +{ + struct tevent_context *ev = talloc_find_parent_bytype(mem_ctx, struct tevent_context); + if (ev == NULL) { + ev = event_context_init(mem_ctx); + } + return ev; +} |