From 454a02a0967e52756b221b89b26e1c949234a496 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 17 Jul 2012 14:28:31 -0500 Subject: [PATCH] unit: Simplify previous commit --- unit/test-util.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/unit/test-util.c b/unit/test-util.c index d3bbf8c2..6658f46f 100644 --- a/unit/test-util.c +++ b/unit/test-util.c @@ -347,7 +347,7 @@ static void test_invalid(void) long nread; short unsigned int exp_code; long exp_res_length; - char *res, *temp, *exp_res = NULL; + char *res, *exp_res = NULL; unsigned char *gsm; res = convert_gsm_to_utf8(invalid_gsm_extended, 0, &nread, &nwritten, @@ -369,13 +369,8 @@ static void test_invalid(void) exp_code = gsm_to_unicode_map[invalid_gsm_extended[1]*2 + 1]; exp_res_length = UTF8_LENGTH(exp_code); - exp_res = g_try_malloc(exp_res_length + 1); - - g_assert(exp_res != NULL); - - temp = exp_res; - temp += g_unichar_to_utf8(exp_code, temp); - *temp = '\0'; + exp_res = g_new0(char, exp_res_length + 1); + g_unichar_to_utf8(exp_code, exp_res); g_assert(g_strcmp0(res, exp_res) == 0); g_assert(nread == exp_res_length);