diff --git a/paddle/fluid/inference/api/api.cc b/paddle/fluid/inference/api/api.cc index ec659f1cfc62be4ee45c006467a1b238a27846e9..a9a6691b044c8e28ade1e6c1c7d76bb44e83c9ee 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; }