Commit fa795f7f authored by thestig's avatar thestig Committed by Commit bot

Remove RefCountedMallocedMemory, it's not used.

Review URL: https://codereview.chromium.org/1550963002

Cr-Commit-Position: refs/heads/master@{#367114}
parent 70db6ba9
......@@ -4,8 +4,6 @@
#include "base/memory/ref_counted_memory.h"
#include <stdlib.h>
#include "base/logging.h"
namespace base {
......@@ -79,22 +77,4 @@ 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
......@@ -124,26 +124,6 @@ class BASE_EXPORT RefCountedString : public RefCountedMemory {
DISALLOW_COPY_AND_ASSIGN(RefCountedString);
};
// An implementation of RefCountedMemory that holds a chunk of memory
// previously allocated with malloc or calloc, and that therefore must be freed
// using free().
class BASE_EXPORT RefCountedMallocedMemory : public base::RefCountedMemory {
public:
RefCountedMallocedMemory(void* data, size_t length);
// Overridden from RefCountedMemory:
const unsigned char* front() const override;
size_t size() const override;
private:
~RefCountedMallocedMemory() override;
unsigned char* data_;
size_t length_;
DISALLOW_COPY_AND_ASSIGN(RefCountedMallocedMemory);
};
} // namespace base
#endif // BASE_MEMORY_REF_COUNTED_MEMORY_H_
......@@ -52,16 +52,6 @@ TEST(RefCountedMemoryUnitTest, RefCountedString) {
EXPECT_EQ('e', mem->front()[1]);
}
TEST(RefCountedMemoryUnitTest, RefCountedMallocedMemory) {
void* data = malloc(6);
memcpy(data, "hello", 6);
scoped_refptr<RefCountedMemory> mem = new RefCountedMallocedMemory(data, 6);
EXPECT_EQ(6U, mem->size());
EXPECT_EQ(0, memcmp("hello", mem->front(), 6));
}
TEST(RefCountedMemoryUnitTest, Equals) {
std::string s1("same");
scoped_refptr<RefCountedMemory> mem1 = RefCountedString::TakeString(&s1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment