From a01ed0c10a54b7c144606316c0bab4ac4de2affd Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 21 Jul 2026 23:54:01 +0000 Subject: [PATCH] Remove an unnecessary munmap() from the unix interface. FossilOrigin-Name: 5fc1ede8b2e559db8a5d783d1065b1f1b2eef73054486552b700706208cbdfd1 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 14 ++------------ 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 7f3d06ca99..0d613eea8b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Random\smakefile\sdoc\supdates.\sNo\sfunctional\schanges. -D 2026-07-21T20:56:55.567 +C Remove\san\sunnecessary\smunmap()\sfrom\sthe\sunix\sinterface. +D 2026-07-21T23:54:01.789 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -727,7 +727,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06 F src/os_kv.c 713336d0c646720a9ccbd5bc6fe217bb4924dd28adea25d83a2af5346cb030e6 F src/os_setup.h 8efc64eda6a6c2f221387eefc2e7e45fd5a3d5c8337a7a83519ba4fbd2957ae2 -F src/os_unix.c 83759942d1ea8d59daed50901c123016f845fada74caf3496b8a2537c9a08838 +F src/os_unix.c 35a8fa7a11c335da484fe887efa23447fef01b63b6bbc032ec3610f94c2db024 F src/os_win.c 1227a3e962b017d676d985a8aec0d64f273991931ea0a0b99773651102f62df4 F src/os_win.h c06ccc3a090cf54202ea58981c298817f3309d4c9e4d52ad0a02927346493721 F src/pager.c 678ee3b68638ee427cc1b071b11181d0f2a827f6cb4d6ec7c12d5fa5f6a752d0 @@ -2217,8 +2217,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c -P a24064919bcc187d5a4d9fa67cb1810fc4e7b9c92596fd2c8e6b0a66bc37e4b3 -R 6c02df29c06cbc9bfa3b4ee8f52145d6 -U stephan -Z 6dbaa3c79fb84d3f8bfc19f8334094ab +P 014ef252c7ea404340a5af52a6615cdddd969a4dbf30712fda538550240bb9fc +R db35009292f15ec72dcee511d1de692d +U drh +Z 5b418561771d835342ccd84f22544807 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 755a598cf0..7996998191 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -014ef252c7ea404340a5af52a6615cdddd969a4dbf30712fda538550240bb9fc +5fc1ede8b2e559db8a5d783d1065b1f1b2eef73054486552b700706208cbdfd1 diff --git a/src/os_unix.c b/src/os_unix.c index ad8259971a..279a95460f 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5589,7 +5589,6 @@ static void unixRemapfile( const char *zErr = "mmap"; int h = pFd->h; /* File descriptor open on db file */ u8 *pOrig = (u8 *)pFd->pMapRegion; /* Pointer to current file mapping */ - i64 nOrig = pFd->mmapSizeActual; /* Size of pOrig region in bytes */ u8 *pNew = 0; /* Location of new mapping */ int flags = PROT_READ; /* Flags to pass to mmap() */ @@ -5607,21 +5606,12 @@ static void unixRemapfile( if( pOrig ){ #if HAVE_MREMAP i64 nReuse = pFd->mmapSize; + pNew = osMremap(pOrig, nReuse, nNew, MREMAP_MAYMOVE); + zErr = "mremap"; #else const int szSyspage = osGetpagesize(); i64 nReuse = (pFd->mmapSize & ~(szSyspage-1)); -#endif u8 *pReq = &pOrig[nReuse]; - - /* Unmap any pages of the existing mapping that cannot be reused. */ - if( nReuse!=nOrig ){ - osMunmap(pReq, nOrig-nReuse); - } - -#if HAVE_MREMAP - pNew = osMremap(pOrig, nReuse, nNew, MREMAP_MAYMOVE); - zErr = "mremap"; -#else pNew = osMmap(pReq, nNew-nReuse, flags, MAP_SHARED, h, nReuse); if( pNew!=MAP_FAILED ){ if( pNew!=pReq ){ -- 2.47.3