summaryrefslogtreecommitdiffstats
path: root/base/memory/discardable_memory_allocator_android.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/memory/discardable_memory_allocator_android.cc')
-rw-r--r--base/memory/discardable_memory_allocator_android.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/base/memory/discardable_memory_allocator_android.cc b/base/memory/discardable_memory_allocator_android.cc
index b1c936a..97e9abd 100644
--- a/base/memory/discardable_memory_allocator_android.cc
+++ b/base/memory/discardable_memory_allocator_android.cc
@@ -16,7 +16,6 @@
#include "base/basictypes.h"
#include "base/containers/hash_tables.h"
#include "base/file_util.h"
-#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/memory/discardable_memory.h"
#include "base/memory/scoped_vector.h"
@@ -66,13 +65,14 @@ bool CreateAshmemRegion(const char* name,
size_t size,
int* out_fd,
void** out_address) {
- base::ScopedFD fd(ashmem_create_region(name, size));
- if (!fd.is_valid()) {
+ int fd = ashmem_create_region(name, size);
+ if (fd < 0) {
DLOG(ERROR) << "ashmem_create_region() failed";
return false;
}
+ file_util::ScopedFD fd_closer(&fd);
- const int err = ashmem_set_prot_region(fd.get(), PROT_READ | PROT_WRITE);
+ const int err = ashmem_set_prot_region(fd, PROT_READ | PROT_WRITE);
if (err < 0) {
DLOG(ERROR) << "Error " << err << " when setting protection of ashmem";
return false;
@@ -88,7 +88,8 @@ bool CreateAshmemRegion(const char* name,
return false;
}
- *out_fd = fd.release();
+ ignore_result(fd_closer.release());
+ *out_fd = fd;
*out_address = address;
return true;
}