r7633: this patch started as an attempt to make the dcerpc code use a given
[kamenim/samba.git] / source4 / libnet / libnet.c
index 56b55426c0a4a9f776af8efa199248067d08bf89..5d66005a27a599f93de11b50434c01bb78d86deb 100644 (file)
 
 #include "includes.h"
 #include "libnet/libnet.h"
+#include "lib/events/events.h"
 
-struct libnet_context *libnet_context_init(void)
+struct libnet_context *libnet_context_init(struct event_context *ev)
 {
-       TALLOC_CTX *mem_ctx;
        struct libnet_context *ctx;
 
-       mem_ctx = talloc_init("libnet_context");
-
-       ctx = talloc(mem_ctx, struct libnet_context);
+       ctx = talloc(NULL, struct libnet_context);
        if (!ctx) {
                return NULL;
        }
 
-       ctx->mem_ctx = mem_ctx;
+       if (ev == NULL) {
+               ev = event_context_init(ctx);
+               if (ev == NULL) {
+                       talloc_free(ctx);
+                       return NULL;
+               }
+       }
+       ctx->event_ctx = ev;
 
        return ctx;
 }
 
-void libnet_context_destroy(struct libnet_context **libnetctx)
-{
-       talloc_free((*libnetctx)->mem_ctx);
-
-       (*libnetctx) = NULL;
-}