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

Unified Diff: base/memory/ref_counted_memory.cc

Issue 78603002: Added RefCountedMallocedMemory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grammar fix Created 7 years, 1 month 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 | « base/memory/ref_counted_memory.h ('k') | base/memory/ref_counted_memory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/ref_counted_memory.cc
diff --git a/base/memory/ref_counted_memory.cc b/base/memory/ref_counted_memory.cc
index b048a6e0d8d2352936e9cb995479058c13f17ba4..b1deee1120167d8517e41b782b7e8690d4e11b80 100644
--- a/base/memory/ref_counted_memory.cc
+++ b/base/memory/ref_counted_memory.cc
@@ -4,6 +4,8 @@
#include "base/memory/ref_counted_memory.h"
+#include <stdlib.h>
+
#include "base/logging.h"
namespace base {
@@ -74,4 +76,22 @@ size_t RefCountedString::size() const {
return data_.size();
}
+RefCountedMallocedMemory::RefCountedMallocedMemory(
+ void* data, size_t length)
+ : data_(reinterpret_cast<unsigned char*>(data)), length_(length) {
+ DCHECK(data || length == 0);
+}
+
+const unsigned char* RefCountedMallocedMemory::front() const {
+ return length_ ? data_ : NULL;
+}
+
+size_t RefCountedMallocedMemory::size() const {
+ return length_;
+}
+
+RefCountedMallocedMemory::~RefCountedMallocedMemory() {
+ free(data_);
+}
+
} // namespace base
« no previous file with comments | « base/memory/ref_counted_memory.h ('k') | base/memory/ref_counted_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698