From 07afc29e90c97980a99c210bcb7e3a149a616ae6 Mon Sep 17 00:00:00 2001 From: liu zhengxi <380185688@qq.com> Date: Tue, 14 Jan 2020 17:38:59 +0800 Subject: [PATCH] Make api.cc malloc consistent with paddle_api.h for PaddleBuf (#22255) --- paddle/fluid/inference/api/api.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/inference/api/api.cc b/paddle/fluid/inference/api/api.cc index ec659f1cfc..a9a6691b04 100644 --- a/paddle/fluid/inference/api/api.cc +++ b/paddle/fluid/inference/api/api.cc @@ -85,7 +85,7 @@ void PaddleBuf::Resize(size_t length) { if (length_ >= length) return; if (memory_owned_) { Free(); - data_ = malloc(length); + data_ = new char[length]; length_ = length; memory_owned_ = true; } else { @@ -103,7 +103,7 @@ void PaddleBuf::Reset(void *data, size_t length) { void PaddleBuf::Free() { if (memory_owned_ && data_) { PADDLE_ENFORCE_GT(length_, 0UL); - free(static_cast(data_)); + delete[] static_cast(data_); data_ = nullptr; length_ = 0; } -- GitLab