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

Unified Diff: native_client_sdk/src/libraries/nacl_io/socket/tcp_node.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/tcp_node.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc b/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc
index df7c8670b812caef41352c6ceec5db9fc6dc2633..4410b5109cb7357c392e3acf41b6db3e52599875 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc
@@ -30,7 +30,9 @@ class TcpWork : public StreamFs::Work {
emitter_(emitter),
data_(NULL) {}
- ~TcpWork() { delete[] data_; }
+ ~TcpWork() {
+ free(data_);
+ }
TCPSocketInterface* TCPInterface() {
return filesystem()->ppapi()->GetTCPSocketInterface();
@@ -63,7 +65,10 @@ class TcpSendWork : public TcpWork {
if (capped_len == 0)
return false;
- data_ = new char[capped_len];
+ data_ = (char*)malloc(capped_len);
+ assert(data_);
+ if (data_ == NULL)
+ return false;
emitter_->ReadOut_Locked(data_, capped_len);
int err = TCPInterface()->Write(node_->socket_resource(),
@@ -126,7 +131,10 @@ class TcpRecvWork : public TcpWork {
if (capped_len == 0)
return false;
- data_ = new char[capped_len];
+ data_ = (char*)malloc(capped_len);
+ assert(data_);
+ if (data_ == NULL)
+ return false;
int err = TCPInterface()->Read(stream->socket_resource(),
data_,
capped_len,
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/socket/packet.cc ('k') | native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698