| 39 #include <cx/linked_list.h> |
39 #include <cx/linked_list.h> |
| 40 #include <cx/hash_map.h> |
40 #include <cx/hash_map.h> |
| 41 #include <cx/compare.h> |
41 #include <cx/compare.h> |
| 42 #include "davqlparser.h" |
42 #include "davqlparser.h" |
| 43 #include "davqlexec.h" |
43 #include "davqlexec.h" |
| |
44 #include "atomic.h" |
| 44 |
45 |
| 45 |
46 |
| 46 DavContext* dav_context_new(void) { |
47 DavContext* dav_context_new(void) { |
| 47 // initialize |
48 // initialize |
| 48 DavContext *context = calloc(1, sizeof(DavContext)); |
49 DavContext *context = calloc(1, sizeof(DavContext)); |
| 92 // add idavprops namespace |
93 // add idavprops namespace |
| 93 if(dav_add_namespace(context, "idavprops", DAV_PROPS_NS)) { |
94 if(dav_add_namespace(context, "idavprops", DAV_PROPS_NS)) { |
| 94 dav_context_destroy(context); |
95 dav_context_destroy(context); |
| 95 return NULL; |
96 return NULL; |
| 96 } |
97 } |
| |
98 |
| |
99 context->ref = 1; |
| 97 |
100 |
| 98 return context; |
101 return context; |
| |
102 } |
| |
103 |
| |
104 void dav_context_ref(DavContext *ctx) { |
| |
105 dav_atomic_inc32(&ctx->ref); |
| |
106 } |
| |
107 |
| |
108 void dav_context_unref(DavContext *ctx) { |
| |
109 if(dav_atomic_dec32(&ctx->ref) == 0) { |
| |
110 dav_context_destroy(ctx); |
| |
111 } |
| 99 } |
112 } |
| 100 |
113 |
| 101 void dav_context_destroy(DavContext *ctx) { |
114 void dav_context_destroy(DavContext *ctx) { |
| 102 // destroy all sessions assoziated with this context |
115 // destroy all sessions assoziated with this context |
| 103 // ctx->sessions destructor must be dav_session_destructor |
116 // ctx->sessions destructor must be dav_session_destructor |