未验证 提交 07afc29e 编写于 作者: L liu zhengxi 提交者: GitHub

Make api.cc malloc consistent with paddle_api.h for PaddleBuf (#22255)

上级 4f1da4ad
......@@ -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<char *>(data_));
delete[] static_cast<char *>(data_);
data_ = nullptr;
length_ = 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册