summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2012-03-28 19:33:57 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2012-03-28 19:33:57 +0000
commite8547d94a9e10abca9fd18819aa36fe1bff1c7ef (patch)
tree5074e97e7c26b143adcfa82c949ac7576479616b /include
parent805473190561d60f06e3b5d63cc30029137cf593 (diff)
downloadlibdom-e8547d94a9e10abca9fd18819aa36fe1bff1c7ef.tar.gz
libdom-e8547d94a9e10abca9fd18819aa36fe1bff1c7ef.tar.bz2
Promote ref/unref in dom_string to be inline -- This implementation is a bit ugly
svn path=/trunk/libdom/; revision=13762
Diffstat (limited to 'include')
-rw-r--r--include/dom/core/string.h23
1 files changed, 20 insertions, 3 deletions
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 <dom/core/exceptions.h>
-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,