You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mxe/src/zziplib-1-fix-mmap.patch

37 lines
1.1 KiB

This file is part of MXE. See LICENSE.md for licensing information.
This patch has been taken from:
http://sourceforge.net/tracker/?func=detail&aid=2995373&group_id=6389&atid=306389
--- zziplib-0.13.59/zzip/__mmap.h 2013-10-03 22:23:32.467619238 -0400
+++ zzip-patched/zzip/__mmap.h 2013-10-04 21:44:16.412881609 -0400
@@ -63,14 +63,15 @@
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;
+ p = MapViewOfFile(fileMapping, FILE_MAP_READ, 0, offs, len);
+ CloseHandle (fileMapping);
+ if (p) return p;
}
return MAP_FAILED;
}
@@ -78,7 +79,6 @@
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) \