From 97c9c9c9d123f1a31f99508d978ad1c77a86f291 Mon Sep 17 00:00:00 2001 From: Siteshwar Vashisht Date: Sun, 3 Mar 2013 16:22:26 +0530 Subject: [PATCH] Use wmemcpy instead of mempcpy in printf builtin --- builtin_printf.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/builtin_printf.cpp b/builtin_printf.cpp index 2b78b23c4..b579d15ec 100644 --- a/builtin_printf.cpp +++ b/builtin_printf.cpp @@ -297,7 +297,6 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion bool have_precision, int precision, wchar_t const *argument) { - wchar_t *p; /* Null-terminated copy of % directive. */ wcstring fmt; /* Create a null-terminated copy of the % directive, with an @@ -328,14 +327,15 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion length_modifier_len = 0; break; } - p = new wchar_t[length + length_modifier_len + 2]; - q = static_cast(mempcpy (p, start, sizeof(wchar_t) * length)); - q = static_cast(mempcpy (q, length_modifier, sizeof(wchar_t) * length_modifier_len)); + + wchar_t p[length + length_modifier_len + 2]; /* Null-terminated copy of % directive. */ + q = wmemcpy(p, start, length) + length; + q = wmemcpy(q, length_modifier, length_modifier_len) + length_modifier_len; *q++ = conversion; *q = L'\0'; + fmt = p; } - fmt = p; switch (conversion) { case L'd': @@ -432,7 +432,6 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion } break; } - free (p); } /* Print the text in FORMAT, using ARGV (with ARGC elements) for @@ -628,4 +627,5 @@ static int builtin_printf(parser_t &parser, wchar_t **argv) argv += args_used; } while (args_used > 0 && argc > 0); + return 0; }