summaryrefslogtreecommitdiff
path: root/src/upb_context.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/upb_context.h')
-rw-r--r--src/upb_context.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/upb_context.h b/src/upb_context.h
index e802454..a04a875 100644
--- a/src/upb_context.h
+++ b/src/upb_context.h
@@ -14,6 +14,7 @@
#include "upb.h"
#include "upb_table.h"
+#include "upb_atomic.h"
struct google_protobuf_FileDescriptorProto;
@@ -38,6 +39,8 @@ struct upb_symtab_entry {
};
struct upb_context {
+ upb_atomic_refcount_t refcount;
+ upb_rwlock_t lock;
struct upb_strtable symtab; /* The context's symbol table. */
struct upb_strtable psymtab; /* Private symbols, for internal use. */
struct upb_msgdef *fds_msg; /* In psymtab, ptr here for convenience. */
@@ -48,9 +51,13 @@ struct upb_context {
struct google_protobuf_FileDescriptorSet **fds;
};
-/* Initializes and frees a upb_context, respectively. */
+/* Initializes a upb_context. Contexts are not freed explicitly, but unref'd
+ * when the caller is done with them. */
bool upb_context_init(struct upb_context *c);
-void upb_context_free(struct upb_context *c);
+INLINE void upb_context_ref(struct upb_context *c) {
+ upb_atomic_ref(&c->refcount);
+}
+void upb_context_unref(struct upb_context *c);
/* Looking up symbols. ********************************************************/
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback