diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-02-14 11:06:50 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-02-23 11:35:11 +0000 |
commit | 34de613deab1c8728118fce389963ecb29ca51e7 (patch) | |
tree | a86e30325ec4e4e48601d432e5312293a28a0010 /libmm-glib/mm-common-helpers.c | |
parent | 6d8610d63ecb8e53e14486533a580ea4f37c644c (diff) |
libmm-glib,common-helpers: make hexstr2bin() return a guint8 array
It makes much more sense than returning a gchar array, as gchar is
signed.
Diffstat (limited to 'libmm-glib/mm-common-helpers.c')
-rw-r--r-- | libmm-glib/mm-common-helpers.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/libmm-glib/mm-common-helpers.c b/libmm-glib/mm-common-helpers.c index 0245fd52..43fff922 100644 --- a/libmm-glib/mm-common-helpers.c +++ b/libmm-glib/mm-common-helpers.c @@ -1686,18 +1686,18 @@ mm_utils_hex2byte (const gchar *hex) return (a << 4) | b; } -gchar * +guint8 * mm_utils_hexstr2bin (const gchar *hex, gssize len, gsize *out_len, GError **error) { const gchar *ipos = hex; - g_autofree gchar *buf = NULL; + g_autofree guint8 *buf = NULL; gsize i; gint a; - gchar *opos -; + guint8 *opos; + if (len < 0) len = strlen (hex); @@ -1723,7 +1723,7 @@ mm_utils_hexstr2bin (const gchar *hex, ipos[0], ipos[1]); return NULL; } - *opos++ = a; + *opos++ = (guint8)a; ipos += 2; } *out_len = len / 2; |