diff options
author | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2012-03-28 19:33:57 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2012-03-28 19:33:57 +0000 |
commit | 79e6a0beb0fa7f8a7d3096947413846a3e9ca546 (patch) | |
tree | 5074e97e7c26b143adcfa82c949ac7576479616b /include | |
parent | 1aa65d46aa7c2861612e912c0ce44f53d5b35df7 (diff) | |
download | libdom-79e6a0beb0fa7f8a7d3096947413846a3e9ca546.tar.gz libdom-79e6a0beb0fa7f8a7d3096947413846a3e9ca546.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.h | 23 |
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, |