mirror of
https://github.com/boostorg/regex.git
synced 2025-07-25 01:57:14 +02:00
Merged regex-4 branch.
[SVN r18430]
This commit is contained in:
@ -23,12 +23,16 @@
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <new>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
|
||||
//
|
||||
// fix: these are declared out of line here to ensure
|
||||
// that dll builds contain the Virtual table for these
|
||||
@ -43,6 +47,71 @@ regbase::regbase()
|
||||
regbase::regbase(const regbase& b)
|
||||
: _flags(b._flags){}
|
||||
|
||||
|
||||
namespace re_detail{
|
||||
|
||||
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page()
|
||||
{
|
||||
#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
_resetstkoflw();
|
||||
#else
|
||||
//
|
||||
// We need to locate the current page being used by the stack,
|
||||
// move to the page below it and then deallocate and protect
|
||||
// that page. Note that ideally we would protect only the lowest
|
||||
// stack page that has been allocated: in practice there
|
||||
// seems to be no easy way to locate this page, in any case as
|
||||
// long as the next page is protected, then Windows will figure
|
||||
// the rest out for us...
|
||||
//
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
MEMORY_BASIC_INFORMATION mi;
|
||||
DWORD previous_protection_status;
|
||||
//
|
||||
// this is an address in our stack space:
|
||||
//
|
||||
LPBYTE page = (LPBYTE)&page;
|
||||
//
|
||||
// Get the current memory page in use:
|
||||
//
|
||||
VirtualQuery(page, &mi, sizeof(mi));
|
||||
//
|
||||
// Go to the page one below this:
|
||||
//
|
||||
page = (LPBYTE)(mi.BaseAddress)-si.dwPageSize;
|
||||
//
|
||||
// Free and protect everything from the start of the
|
||||
// allocation range, to the end of the page below the
|
||||
// one in use:
|
||||
//
|
||||
if (!VirtualFree(mi.AllocationBase, (LPBYTE)page - (LPBYTE)mi.AllocationBase, MEM_DECOMMIT)
|
||||
|| !VirtualProtect(page, si.dwPageSize, PAGE_GUARD | PAGE_READWRITE, &previous_protection_status))
|
||||
{
|
||||
throw std::bad_exception();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_regex_exception(const std::string& msg)
|
||||
{
|
||||
bad_expression e(msg);
|
||||
throw_exception(e);
|
||||
}
|
||||
|
||||
#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3)
|
||||
|
||||
mem_block_cache block_cache = { 0, };
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace re_detail
|
||||
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if defined(BOOST_RE_USE_VCL) && defined(BOOST_REGEX_BUILD_DLL)
|
||||
@ -58,3 +127,4 @@ int WINAPI DllEntryPoint(HINSTANCE , unsigned long , void*)
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user