summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/shared_memory.h3
-rw-r--r--base/shared_memory_posix.cc6
-rw-r--r--base/shared_memory_win.cc6
3 files changed, 15 insertions, 0 deletions
diff --git a/base/shared_memory.h b/base/shared_memory.h
index a368d9f..ea72069 100644
--- a/base/shared_memory.h
+++ b/base/shared_memory.h
@@ -61,6 +61,9 @@ class SharedMemory {
// Return invalid handle (see comment above for exact definition).
static SharedMemoryHandle NULLHandle();
+ // Close a shared memory handle.
+ static void CloseHandle(const SharedMemoryHandle& handle);
+
// Creates or opens a shared memory segment based on a name.
// If read_only is true, opens the memory as read-only.
// If open_existing is true, and the shared memory already exists,
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index 2f0fe22..fe4b225 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -70,6 +70,12 @@ SharedMemoryHandle SharedMemory::NULLHandle() {
return SharedMemoryHandle();
}
+// static
+void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) {
+ DCHECK(handle.fd >= 0);
+ close(handle.fd);
+}
+
bool SharedMemory::Create(const std::wstring &name, bool read_only,
bool open_existing, size_t size) {
read_only_ = read_only;
diff --git a/base/shared_memory_win.cc b/base/shared_memory_win.cc
index 66f8fb6..dd4c73b 100644
--- a/base/shared_memory_win.cc
+++ b/base/shared_memory_win.cc
@@ -55,6 +55,12 @@ SharedMemoryHandle SharedMemory::NULLHandle() {
return NULL;
}
+// static
+void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) {
+ DCHECK(handle != NULL);
+ ::CloseHandle(handle);
+}
+
bool SharedMemory::Create(const std::wstring &name, bool read_only,
bool open_existing, size_t size) {
DCHECK(mapped_file_ == NULL);