Use json_is_true() in place of json_boolean_value() for compatibility
[trust_router.git] / tr / tr.c
diff --git a/tr/tr.c b/tr/tr.c
index 5243bc4..d79ca76 100644 (file)
--- a/tr/tr.c
+++ b/tr/tr.c
 
 #include <stdlib.h>
 #include <string.h>
+#include <talloc.h>
+#include <tr_config.h>
 #include <tr.h>
 
-TR_INSTANCE *tr_create() {
-  TR_INSTANCE *tr = NULL;
-  if (tr = malloc(sizeof(TR_INSTANCE)))
-    memset(tr, 0, sizeof(TR_INSTANCE));
+TR_INSTANCE *tr_create(TALLOC_CTX *mem_ctx) {
+  TALLOC_CTX *tmp_ctx=talloc_new(NULL);
+  TR_INSTANCE *tr=talloc_zero(tmp_ctx, TR_INSTANCE);
+  if (tr != NULL) {
+    tr->cfg_mgr=tr_cfg_mgr_new(tr);
+    if (tr->cfg_mgr != NULL) {
+      /* success, hand over ownership */
+      talloc_steal(mem_ctx, tr);
+    }
+  }
+  talloc_free(tmp_ctx);
   return tr;
 }
+
+void tr_destroy(TR_INSTANCE *tr) {
+  talloc_free (tr);
+}