From 79e6a0beb0fa7f8a7d3096947413846a3e9ca546 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Wed, 28 Mar 2012 19:33:57 +0000 Subject: Promote ref/unref in dom_string to be inline -- This implementation is a bit ugly svn path=/trunk/libdom/; revision=13762 --- include/dom/core/string.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'include/dom') diff --git a/include/dom/core/string.h b/include/dom/core/string.h index 84db35a..059a21f 100644 --- a/include/dom/core/string.h +++ b/include/dom/core/string.h @@ -16,12 +16,29 @@ #include -typedef struct dom_string dom_string; +typedef struct dom_string { + uint32_t refcnt; +} dom_string; + /* Claim a reference on a DOM string */ -dom_string *dom_string_ref(dom_string *str); +static inline dom_string *dom_string_ref(dom_string *str) +{ + if (str != NULL) + str->refcnt++; + return str; +} + +/* Destroy a DOM string */ +void dom_string_destroy(dom_string *str); + /* Release a reference on a DOM string */ -void dom_string_unref(dom_string *str); +static inline void dom_string_unref(dom_string *str) +{ + if ((str != NULL) && (--(str->refcnt) == 0)) { + dom_string_destroy(str); + } +} /* Create a DOM string from a string of characters */ dom_exception dom_string_create(const uint8_t *ptr, size_t len, -- cgit v1.2.3