From: Patrick Lam Date: Wed, 19 Apr 2006 16:53:50 +0000 (+0000) Subject: Dominic Lachowicz X-Git-Tag: fc-2_3_95~5 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=93f67dfc73601ea2f73c1fa2d9f4f13a84cf1232;p=fontconfig.git Dominic Lachowicz Implement mmap-like code for Windows using MapViewOfFile. --- diff --git a/ChangeLog b/ChangeLog index 15b3662..0f83c24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,13 @@ Bump version to 2.3.95. +2006-04-19 Patrick Lam + Dominic Lachowicz + + * src/fccache.c (FcDirCacheConsume): + + Implement mmap-like code for Windows using MapViewOfFile. + 2006-04-19 Patrick Lam * src/fccache.c (FcDirCacheConsume, FcCacheNextOffset): diff --git a/src/fccache.c b/src/fccache.c index c98c001..8f25b2c 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -27,12 +27,12 @@ #include #include #include -#include #include "fcint.h" -#include #if defined(HAVE_MMAP) || defined(__CYGWIN__) +# include # include -# include +#elif defined(_WIN32) +# include #endif #define ENDIAN_TEST 0x12345678 @@ -1203,6 +1203,23 @@ FcDirCacheConsume (int fd, const char * dir, FcFontSet *set, FcConfig *config) PROT_READ, MAP_SHARED, fd, pos); if (current_dir_block == MAP_FAILED) return FcFalse; +#elif defined(_WIN32) + { + HANDLE hFileMap; + + hFileMap = CreateFileMapping((HANDLE) _get_osfhandle(fd), NULL, PAGE_READONLY, 0, 0, NULL); + if (hFileMap == NULL) + return FcFalse; + + current_dir_block = MapViewOfFile (hFileMap, FILE_MAP_READ, 0, 0, metadata.count + pos); + if (current_dir_block == NULL) + { + CloseHandle (hFileMap); + return FcFalse; + } + + current_dir_block = (void *)((char *)current_dir_block + pos); + } #else current_dir_block = malloc (metadata.count); if (!current_dir_block)