diff options
Diffstat (limited to 'src/xmpp/jid.c')
-rw-r--r-- | src/xmpp/jid.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/xmpp/jid.c b/src/xmpp/jid.c index 33c3d19f..af0a606b 100644 --- a/src/xmpp/jid.c +++ b/src/xmpp/jid.c @@ -76,6 +76,7 @@ jid_create(const gchar* const str) result->resourcepart = NULL; result->barejid = NULL; result->fulljid = NULL; + result->refcnt = 1; gchar* atp = g_utf8_strchr(trimmed, -1, '@'); gchar* slashp = g_utf8_strchr(trimmed, -1, '/'); @@ -120,11 +121,29 @@ jid_create_from_bare_and_resource(const char* const barejid, const char* const r } void +jid_auto_destroy(Jid** jid) +{ + if (jid == NULL) + return; + jid_destroy(*jid); +} + +void +jid_ref(Jid* jid) +{ + jid->refcnt++; +} + +void jid_destroy(Jid* jid) { if (jid == NULL) { return; } + if (jid->refcnt > 1) { + jid->refcnt--; + return; + } g_free(jid->str); g_free(jid->localpart); |