| 2002 | |
| 2003 | |
| 2004 | void SharedMemoryBase::unmapObject(CheckStatusWrapper* statusVector, UCHAR** object_pointer, ULONG object_length) |
| 2005 | { |
| 2006 | /************************************** |
| 2007 | * |
| 2008 | * I S C _ u n m a p _ o b j e c t |
| 2009 | * |
| 2010 | ************************************** |
| 2011 | * |
| 2012 | * Functional description |
| 2013 | * Try to unmap an object given a file mapping. |
| 2014 | * Zero the object pointer after a successful unmap. |
| 2015 | * |
| 2016 | **************************************/ |
| 2017 | const size_t page_size = getSystemPageSize(statusVector); |
| 2018 | if (!page_size) |
| 2019 | return; |
| 2020 | |
| 2021 | // Compute the start and end page-aligned addresses which contain the mapped object. |
| 2022 | |
| 2023 | char* const start = (char*) ((U_IPTR) (*object_pointer) & ~(page_size - 1)); |
| 2024 | char* const end = |
| 2025 | (char*) ((U_IPTR) ((*object_pointer + object_length) + (page_size - 1)) & ~(page_size - 1)); |
| 2026 | const size_t length = end - start; |
| 2027 | |
| 2028 | if (munmap(start, length) == -1) |
| 2029 | { |
| 2030 | error(statusVector, "munmap", errno); |
| 2031 | return; // false; |
| 2032 | } |
| 2033 | |
| 2034 | *object_pointer = NULL; |
| 2035 | return; // true; |
| 2036 | } |
| 2037 | #endif // HAVE_MMAP |
| 2038 | |
| 2039 |
no test coverage detected