Boost logo

Boost :

From: (noreply_at_[hidden])
Date: 2006-08-01 16:10:14

Bugs item #1532684, was opened at 2006-08-01 13:10
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Changing size of memory-mapped file on Windows

Initial Comment:
My email address is

There is a bug in
mapped_file_source::open_impl(mapped_file_params p)

This function does not correctly check for errors from
SetFilePointer, as documented in the MSDN page below.
(See "Case Two: calling the function with
lpDistanceToMoveHigh != NULL")

Current code:

        ::SetFilePointer(pimpl_->handle_, sizelow,
&sizehigh, FILE_BEGIN);
        if (::GetLastError() != NO_ERROR ||
            detail::cleanup_and_throw(*pimpl_, "failed
setting file size");

Should be:

        DWORD dwResult =
::SetFilePointer(pimpl_->handle_, sizelow, &sizehigh,
        if (dwResult == INVALID_SET_FILE_POINTER
::GetLastError() != NO_ERROR ||
            detail::cleanup_and_throw(*pimpl_, "failed
setting file size");

Even after this fix, the ability to resize an existing
file is not really useful because the file is
apparently recreated rather than resized. I am working
around this by resizing the file using system calls,
but I wonder if this is how the function is supposed to
You can respond by visiting:
Take Surveys. Earn Cash. Influence the Future of IT
Join's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
Boost-bugs mailing list

Boost list run by bdawes at, gregod at, cpdaniel at, john at