Does not leak memory with ctx and backend
[cascardo/atompub.git] / src / ctx.c
index 8904b38..73f17fc 100644 (file)
--- a/src/ctx.c
+++ b/src/ctx.c
@@ -35,9 +35,20 @@ atom_ctx_new ()
   ctx = g_slice_new (AtomCtx);
   ctx->error = NULL;
   ctx->config_data = NULL;
+  ctx->backend = NULL;
   return ctx;
 }
 
+void
+atom_ctx_delete (AtomCtx *ctx)
+{
+  if (ctx->error)
+    g_error_free (ctx->error);
+  if (ctx->backend)
+    atom_backend_delete (ctx->backend);
+  g_slice_free (AtomCtx, ctx);
+}
+
 void
 atom_error_set (AtomCtx *ctx, GError *error)
 {