From 63580a902ee7cc4905be7c3c47812f6e608d04b1 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Sun, 20 May 2012 15:08:20 -0700 Subject: [PATCH] formatter: replace malloc with new This will throw exception if allocation failed. Signed-off-by: Yehuda Sadeh --- src/common/Formatter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/Formatter.cc b/src/common/Formatter.cc index 30dbf2dfc6fdf..4f72753f42664 100644 --- a/src/common/Formatter.cc +++ b/src/common/Formatter.cc @@ -83,10 +83,10 @@ void JSONFormatter::print_comma(json_formatter_stack_entry_d& entry) void JSONFormatter::print_quoted_string(const char *s) { int len = escape_json_attr_len(s); - char *escaped = (char*)malloc(len); + char *escaped = new char[len]; escape_json_attr(s, escaped); m_ss << '\"' << escaped << '\"'; - free(escaped); + delete[] escaped; } void JSONFormatter::print_name(const char *name) -- 2.39.5