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

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
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..26bbf81f08cdefe5268eefa29d451ca51db04b5e 100644
--- a/native_client_sdk/src/libraries/nacl_io/fifo_char.cc
+++ b/native_client_sdk/src/libraries/nacl_io/fifo_char.cc
@@ -14,11 +14,11 @@ namespace nacl_io {
FIFOChar::FIFOChar(size_t size)
: buffer_(NULL), size_(size), avail_(0), tail_(0) {
if (size)
- buffer_ = new char[size];
+ buffer_ = (char*)malloc(size);
binji 2014/08/05 19:30:29 we should probably check for NULL returns for all
Sam Clegg 2014/08/06 09:10:32 Done. Although there is not much useful we can do
}
FIFOChar::~FIFOChar() {
- delete[] buffer_;
+ free(buffer_);
}
bool FIFOChar::IsEmpty() {
@@ -34,13 +34,8 @@ 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);
size_ = len;
return true;
}

Powered by Google App Engine
This is Rietveld 408576698