diff options
author | Michael Vetter <jubalh@iodoru.org> | 2023-01-19 11:05:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-19 11:05:42 +0100 |
commit | 494512c25cabc2271b4132f19ad38fb8edee1afa (patch) | |
tree | e7131bb283b4731cbe0e1c595bfd7b3faa349c77 /src/xmpp/jid.c | |
parent | 78496d6226cb6f00ba3b14db479497ab3cfc8160 (diff) | |
parent | 99ffaf0a008cabbc0855b0d3b818ce9a2ad6bd62 (diff) | |
download | profani-tty-494512c25cabc2271b4132f19ad38fb8edee1afa.tar.gz |
Merge pull request #1780 from profanity-im/minor-improvements
Minor improvements
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); |