#ifndef MAP_FAILED
#define MAP_FAILED 0
#endif
-/* we (ab)use the "*user" variable to store the FileMapping handle */
- /* which assumes (sizeof(long) == sizeof(HANDLE)) */
+/* we had used the plugin->sys variable for (user) but not anymore */
static size_t win32_getpagesize (void)
{
return 0;
{
HANDLE hFile = (HANDLE)_get_osfhandle(fd);
+ HANDLE fileMapping = NULL;
if (hFile)
- *user = (int) CreateFileMapping (hFile, 0, PAGE_READONLY, 0, 0, NULL);
- if (*user)
+ fileMapping = CreateFileMapping (hFile, 0, PAGE_READONLY, 0, 0, NULL);
+ if (fileMapping != NULL)
{
- char* p = 0;
- p = MapViewOfFile(*(HANDLE*)user, FILE_MAP_READ, 0, offs, len);
- if (p) return p + offs;
- CloseHandle (*(HANDLE*)user); *user = 1;
+ char* p = MapViewOfFile(fileMapping, FILE_MAP_READ, 0, offs, len);
+ CloseHandle (fileMapping); *user = 1;
+ if (p) return p;
}
return MAP_FAILED;
}
static void win32_munmap (long* user, char* fd_map, size_t len)
{
UnmapViewOfFile (fd_map);
- CloseHandle (*(HANDLE*)user); *user = 1;
}
#define _zzip_mmap(user, fd, offs, len) \