libmm-glib,common-helpers: make hexstr2bin() return a guint8 array

It makes much more sense than returning a gchar array, as gchar is
signed.
This commit is contained in:
Aleksander Morgado
2021-02-23 11:35:11 +00:00
parent 6d8610d63e
commit 34de613dea
11 changed files with 48 additions and 52 deletions
+5 -5
View File
@@ -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;
+1 -1
View File
@@ -181,7 +181,7 @@ gchar *mm_get_string_unquoted_from_match_info (GMatchInfo *match_info,
const gchar *mm_sms_delivery_state_get_string_extended (guint delivery_state);
gint mm_utils_hex2byte (const gchar *hex);
gchar *mm_utils_hexstr2bin (const gchar *hex, gssize len, gsize *out_len, GError **error);
guint8 *mm_utils_hexstr2bin (const gchar *hex, gssize len, gsize *out_len, GError **error);
gchar *mm_utils_bin2hexstr (const guint8 *bin, gsize len);
gboolean mm_utils_ishexstr (const gchar *hex);