diff options
author | durner <durner@140774ce-b5e7-0310-ab8b-a85725594a96> | 2010-12-13 21:04:59 +0000 |
---|---|---|
committer | durner <durner@140774ce-b5e7-0310-ab8b-a85725594a96> | 2010-12-13 21:04:59 +0000 |
commit | 88f479e62cd41af87784b5449ffba32128b079f5 (patch) | |
tree | f2d6dde00798cede5d4152a1718515473264e31c | |
parent | bd89a5cc6d22d06047356154cf3e038f4607047e (diff) |
fix MinGW munmap (#1628)
git-svn-id: https://gnunet.org/svn/gnunet@13899 140774ce-b5e7-0310-ab8b-a85725594a96
-rw-r--r-- | src/util/disk.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/util/disk.c b/src/util/disk.c index 0b37da8c2a..639b4ca109 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -1478,6 +1478,11 @@ GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, */ struct GNUNET_DISK_MapHandle { + /** + * Address where the map is in memory. + */ + void *addr; + #ifdef MINGW /** * Underlying OS handle. @@ -1485,11 +1490,6 @@ struct GNUNET_DISK_MapHandle HANDLE h; #else /** - * Address where the map is in memory. - */ - void *addr; - - /** * Number of bytes mapped. */ size_t len; @@ -1523,7 +1523,6 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, #ifdef MINGW DWORD mapAccess, protect; - void *ret; if ((access & GNUNET_DISK_MAP_TYPE_READ) && (access & GNUNET_DISK_MAP_TYPE_WRITE)) @@ -1556,15 +1555,15 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, return NULL; } - ret = MapViewOfFile ((*m)->h, mapAccess, 0, 0, len); - if (!ret) + (*m)->addr = MapViewOfFile ((*m)->h, mapAccess, 0, 0, len); + if (!(*m)->addr) { SetErrnoFromWinError (GetLastError ()); CloseHandle ((*m)->h); GNUNET_free (*m); } - return ret; + return (*m)->addr; #else int prot; @@ -1602,7 +1601,7 @@ GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h) } #ifdef MINGW - ret = UnmapViewOfFile (h->h) ? GNUNET_OK : GNUNET_SYSERR; + ret = UnmapViewOfFile (h->addr) ? GNUNET_OK : GNUNET_SYSERR; if (ret != GNUNET_OK) SetErrnoFromWinError (GetLastError ()); if (!CloseHandle (h->h) && (ret == GNUNET_OK)) |