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

Unified Diff: native_client_sdk/src/libraries/nacl_io/fifo_char.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
« no previous file with comments | « no previous file | native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/libraries/nacl_io/fifo_char.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/fifo_char.cc b/native_client_sdk/src/libraries/nacl_io/fifo_char.cc
index 56245559724f4fd7c5c4b56ddef31819d28ed929..144f5842be632b750fd6c64f69b79c282683a085 100644
--- a/native_client_sdk/src/libraries/nacl_io/fifo_char.cc
+++ b/native_client_sdk/src/libraries/nacl_io/fifo_char.cc
@@ -4,6 +4,7 @@
#include "nacl_io/fifo_char.h"
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
@@ -13,12 +14,14 @@ namespace nacl_io {
FIFOChar::FIFOChar(size_t size)
: buffer_(NULL), size_(size), avail_(0), tail_(0) {
- if (size)
- buffer_ = new char[size];
+ if (size) {
+ buffer_ = (char*)malloc(size);
+ assert(buffer_ != NULL);
+ }
}
FIFOChar::~FIFOChar() {
- delete[] buffer_;
+ free(buffer_);
}
bool FIFOChar::IsEmpty() {
@@ -34,13 +37,11 @@ bool FIFOChar::Resize(size_t len) {
if (len < avail_)
return false;
- // Read current data into new buffer
- char* data = new char[len];
- avail_ = Read(data, avail_);
-
- // Replace buffer
- delete[] buffer_;
- buffer_ = data;
+ // Resize buffer
+ buffer_ = (char*)realloc(buffer_, len);
+ assert(buffer_ != NULL);
+ if (buffer_ == NULL)
+ return false;
size_ = len;
return true;
}
« no previous file with comments | « no previous file | native_client_sdk/src/libraries/nacl_io/httpfs/http_fs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698