Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: native_client_sdk/src/libraries/nacl_io/socket/packet.cc

Issue 443693002: [NaCl SDK] nacl_io: Remove use of new/delete for data buffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/nacl_io/socket/packet.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/packet.cc b/native_client_sdk/src/libraries/nacl_io/socket/packet.cc
index f437d0983f0238543cb07125d5e43042e86b68a6..69a894f64f14a6bb29c7ec1f8d5362f4a649639f 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/packet.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/packet.cc
@@ -4,6 +4,7 @@
#include "nacl_io/socket/packet.h"
+#include <assert.h>
#include <string.h>
#include "nacl_io/pepper_interface.h"
@@ -17,19 +18,14 @@ Packet::Packet(PepperInterface* ppapi)
Packet::~Packet() {
if ((NULL != ppapi_) && addr_)
ppapi_->ReleaseResource(addr_);
- delete[] buffer_;
-}
-
-void Packet::Take(const void* buffer, size_t len, PP_Resource addr) {
- addr_ = addr;
- len_ = len;
- buffer_ = static_cast<char*>(const_cast<void*>(buffer));
+ free(buffer_);
}
void Packet::Copy(const void* buffer, size_t len, PP_Resource addr) {
addr_ = addr;
len_ = len;
- buffer_ = new char[len];
+ buffer_ = (char*)malloc(len);
+ assert(buffer_);
memcpy(buffer_, buffer, len);
if (addr && (NULL != ppapi_))
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/socket/packet.h ('k') | native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698