libidav/webdav.c

branch
dav-2
changeset 914
42c6b071b231
parent 893
38800d479cd4
--- a/libidav/webdav.c	Sat Feb 14 18:11:29 2026 +0100
+++ b/libidav/webdav.c	Sat Jun 20 19:00:56 2026 +0200
@@ -41,6 +41,7 @@
 #include <cx/compare.h>
 #include "davqlparser.h"
 #include "davqlexec.h"
+#include "atomic.h"
 
 
 DavContext* dav_context_new(void) {
@@ -94,10 +95,22 @@
         dav_context_destroy(context);
         return NULL;
     }   
+    
+    context->ref = 1;
 
     return context;
 }
 
+void dav_context_ref(DavContext *ctx) {
+    dav_atomic_inc32(&ctx->ref);
+}
+
+void dav_context_unref(DavContext *ctx) {
+    if(dav_atomic_dec32(&ctx->ref) == 0) {
+        dav_context_destroy(ctx);
+    }
+}
+
 void dav_context_destroy(DavContext *ctx) {
     // destroy all sessions assoziated with this context
     // ctx->sessions destructor must be dav_session_destructor

mercurial