From: Nils Durner Date: Mon, 13 Dec 2010 21:04:59 +0000 (+0000) Subject: fix MinGW munmap (#1628) X-Git-Tag: initial-import-from-subversion-38251~19532 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1bc24dcb3cf15f81a21017d0f210c3e87c21df78;p=oweals%2Fgnunet.git fix MinGW munmap (#1628) --- diff --git a/src/util/disk.c b/src/util/disk.c index 0b37da8c2..639b4ca10 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -1478,17 +1478,17 @@ 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. */ HANDLE h; #else - /** - * Address where the map is in memory. - */ - void *addr; - /** * Number of bytes mapped. */ @@ -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))