summaryrefslogtreecommitdiff
path: root/src/upb_enum.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/upb_enum.h')
-rw-r--r--src/upb_enum.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/upb_enum.h b/src/upb_enum.h
index cad240a..e43a203 100644
--- a/src/upb_enum.h
+++ b/src/upb_enum.h
@@ -10,10 +10,14 @@
#define UPB_ENUM_H_
#include <stdint.h>
+#include "upb_atomic.h"
+#include "upb_context.h"
#include "upb_table.h"
#include "descriptor.h"
struct upb_enum {
+ upb_atomic_refcount_t refcount;
+ struct upb_context *context;
struct google_protobuf_EnumDescriptorProto *descriptor;
struct upb_strtable nametoint;
struct upb_inttable inttoname;
@@ -29,10 +33,20 @@ struct upb_enum_iton_entry {
struct upb_string *string;
};
+INLINE void upb_enum_ref(struct upb_enum *e) {
+ if(upb_atomic_ref(&e->refcount)) upb_context_ref(e->context);
+}
+
+INLINE void upb_enum_unref(struct upb_enum *e) {
+ if(upb_atomic_unref(&e->refcount)) upb_context_unref(e->context);
+}
+
+
/* Initializes and frees an enum, respectively. Caller retains ownership of
* ed, but it must outlive e. */
void upb_enum_init(struct upb_enum *e,
- struct google_protobuf_EnumDescriptorProto *ed);
+ struct google_protobuf_EnumDescriptorProto *ed,
+ struct upb_context *c);
void upb_enum_free(struct upb_enum *e);
#endif /* UPB_ENUM_H_ */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback