From 7179f51176e1f3af53694e09d7ea2ca602403cf1 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 10 Dec 2014 02:21:00 +0100 Subject: no more direct allocations, always use macros, unless using alloca MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-kbdc/builtin-functions.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/mds-kbdc/builtin-functions.c') diff --git a/src/mds-kbdc/builtin-functions.c b/src/mds-kbdc/builtin-functions.c index fbff16f..7cd13b7 100644 --- a/src/mds-kbdc/builtin-functions.c +++ b/src/mds-kbdc/builtin-functions.c @@ -29,24 +29,24 @@ /** * Define useful data for built-in function with 2 parameters */ -#define define_2 \ - const char32_t* restrict a = *args++; \ - const char32_t* restrict b = *args++; \ - size_t an = string_length(a); \ - size_t bn = string_length(b); \ - size_t i, n = an > bn ? an : bn; \ - char32_t* restrict rc = malloc((n + 1) * sizeof(char32_t)); \ - fail_if (rc == NULL); \ +#define define_2 \ + const char32_t* restrict a = *args++; \ + const char32_t* restrict b = *args++; \ + size_t an = string_length(a); \ + size_t bn = string_length(b); \ + size_t i, n = an > bn ? an : bn; \ + char32_t* restrict rc; \ + fail_if (xmalloc(rc, n + 1, char32_t)); \ rc[n] = -1 /** * Define useful data for built-in function with 1 parameter */ -#define define_1 \ - const char32_t* restrict a = *args++; \ - size_t i, n = string_length(a); \ - char32_t* restrict rc = malloc((n + 1) * sizeof(char32_t)); \ - fail_if (rc == NULL); \ +#define define_1 \ + const char32_t* restrict a = *args++; \ + size_t i, n = string_length(a); \ + char32_t* restrict rc; \ + fail_if (xmalloc(rc, n + 1, char32_t)); \ rc[n] = -1 /** -- cgit v1.2.3-70-g09d2