util: Convert pack7_bit / unpack_7bit to use l_malloc

This commit is contained in:
Denis Kenzior 2018-12-20 15:43:08 -06:00
parent 4e74b7b182
commit d5f117be80
4 changed files with 10 additions and 8 deletions

View File

@ -27,6 +27,7 @@
#include <stdlib.h>
#include <glib.h>
#include <ell/ell.h>
#include <ofono/types.h>
#include "simutil.h"
@ -800,7 +801,7 @@ static char *sim_network_name_parse(const unsigned char *buffer, int length,
ret = convert_gsm_to_utf8(unpacked_buf, written, NULL, NULL, 0);
g_free(unpacked_buf);
l_free(unpacked_buf);
break;
case 0x10:

View File

@ -33,6 +33,7 @@
#include <unistd.h>
#include <glib.h>
#include <ell/ell.h>
#include "util.h"
#include "storage.h"
@ -677,7 +678,7 @@ gboolean sms_decode_address_field(const unsigned char *pdu, int len,
utf8 = convert_gsm_to_utf8(res, written, NULL, NULL, 0);
g_free(res);
l_free(res);
if (utf8 == NULL)
return FALSE;
@ -4736,7 +4737,7 @@ char *ussd_decode(int dcs, int len, const unsigned char *data)
return NULL;
utf8 = convert_gsm_to_utf8(unpacked, written, NULL, NULL, 0);
g_free(unpacked);
l_free(unpacked);
break;
}

View File

@ -28,6 +28,7 @@
#include <stdint.h>
#include <glib.h>
#include <ell/ell.h>
#include <ofono/types.h>
#include "smsutil.h"
@ -102,7 +103,7 @@ static char *decode_text(unsigned char dcs, int len, const unsigned char *data)
utf8 = convert_gsm_to_utf8(unpacked, written,
NULL, NULL, 0);
g_free(unpacked);
l_free(unpacked);
break;
}
case SMS_CHARSET_8BIT:

View File

@ -3412,8 +3412,7 @@ unsigned char *unpack_7bit(const unsigned char *in, long len, int byte_offset,
bool ussd, long max_to_unpack,
long *items_written, unsigned char terminator)
{
unsigned char *buf = g_new(unsigned char,
len * 8 / 7 + (terminator ? 1 : 0));
unsigned char *buf = l_malloc(len * 8 / 7 + (terminator ? 1 : 0));
return unpack_7bit_own_buf(in, len, byte_offset, ussd, max_to_unpack,
items_written, terminator, buf);
@ -3520,9 +3519,9 @@ unsigned char *pack_7bit(const unsigned char *in, long len, int byte_offset,
/* Round up number of bytes, must append <cr> if true */
if (ussd && ((total_bits % 8) == 0) && (in[len - 1] == '\r'))
buf = g_new(unsigned char, (total_bits + 14) / 8);
buf = l_malloc((total_bits + 14) / 8);
else
buf = g_new(unsigned char, (total_bits + 7) / 8);
buf = l_malloc((total_bits + 7) / 8);
return pack_7bit_own_buf(in, len, byte_offset, ussd, items_written,
terminator, buf);