mirror of
https://github.com/boostorg/regex.git
synced 2025-07-14 04:46:36 +02:00
Added fixes for:
Compilers that pretend to be Visual C++ export of memory management code [SVN r18955]
This commit is contained in:
@ -232,13 +232,13 @@ using std::distance;
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(BOOST_MSVC) || defined(__ICL)
|
#if defined(_MSC_VER) && (_MSC_VER >= 1200) && defined(_MSC_EXTENSIONS)
|
||||||
# if defined(_DEBUG)
|
# if defined(_DEBUG)
|
||||||
# define BOOST_REGEX_CALL __cdecl
|
# define BOOST_REGEX_CALL __cdecl
|
||||||
# else
|
# else
|
||||||
# define BOOST_REGEX_CALL __fastcall
|
# define BOOST_REGEX_CALL __fastcall
|
||||||
# endif
|
# endif
|
||||||
# define BOOST_REGEX_CCALL __stdcall
|
# define BOOST_REGEX_CCALL __cdecl
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
@ -556,5 +556,19 @@ inline void pointer_construct(T* p, const T& t)
|
|||||||
}} // namespaces
|
}} // namespaces
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* helper memory allocation functions:
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
|
||||||
|
namespace boost{ namespace re_detail{
|
||||||
|
|
||||||
|
BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
|
||||||
|
BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
|
||||||
|
|
||||||
|
}} // namespaces
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -442,7 +442,6 @@ private:
|
|||||||
#ifdef BOOST_REGEX_RECURSIVE
|
#ifdef BOOST_REGEX_RECURSIVE
|
||||||
#include <boost/regex/v4/perl_matcher_recursive.hpp>
|
#include <boost/regex/v4/perl_matcher_recursive.hpp>
|
||||||
#else
|
#else
|
||||||
#include <boost/regex/v4/mem_block_cache.hpp>
|
|
||||||
#include <boost/regex/v4/perl_matcher_non_recursive.hpp>
|
#include <boost/regex/v4/perl_matcher_non_recursive.hpp>
|
||||||
#endif
|
#endif
|
||||||
// this one has to be last:
|
// this one has to be last:
|
||||||
|
@ -91,7 +91,7 @@ struct save_state_init
|
|||||||
save_state_init(saved_state** base, saved_state** end)
|
save_state_init(saved_state** base, saved_state** end)
|
||||||
: stack(base)
|
: stack(base)
|
||||||
{
|
{
|
||||||
*base = static_cast<saved_state*>(block_cache.get());
|
*base = static_cast<saved_state*>(get_mem_block());
|
||||||
*end = reinterpret_cast<saved_state*>(reinterpret_cast<char*>(*base)+BOOST_REGEX_BLOCKSIZE);
|
*end = reinterpret_cast<saved_state*>(reinterpret_cast<char*>(*base)+BOOST_REGEX_BLOCKSIZE);
|
||||||
--(*end);
|
--(*end);
|
||||||
new (*end)saved_state(0);
|
new (*end)saved_state(0);
|
||||||
@ -99,7 +99,7 @@ struct save_state_init
|
|||||||
}
|
}
|
||||||
~save_state_init()
|
~save_state_init()
|
||||||
{
|
{
|
||||||
block_cache.put(*stack);
|
put_mem_block(*stack);
|
||||||
*stack = 0;
|
*stack = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -145,7 +145,7 @@ void perl_matcher<BidiIterator, Allocator, traits, Allocator2>::extend_stack()
|
|||||||
--used_block_count;
|
--used_block_count;
|
||||||
saved_state* stack_base;
|
saved_state* stack_base;
|
||||||
saved_state* backup_state;
|
saved_state* backup_state;
|
||||||
stack_base = static_cast<saved_state*>(block_cache.get());
|
stack_base = static_cast<saved_state*>(get_mem_block());
|
||||||
backup_state = reinterpret_cast<saved_state*>(reinterpret_cast<char*>(stack_base)+BOOST_REGEX_BLOCKSIZE);
|
backup_state = reinterpret_cast<saved_state*>(reinterpret_cast<char*>(stack_base)+BOOST_REGEX_BLOCKSIZE);
|
||||||
saved_extra_block* block = static_cast<saved_extra_block*>(backup_state);
|
saved_extra_block* block = static_cast<saved_extra_block*>(backup_state);
|
||||||
--block;
|
--block;
|
||||||
@ -799,7 +799,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::unwind_extra_blo
|
|||||||
m_stack_base = pmp->base;
|
m_stack_base = pmp->base;
|
||||||
m_backup_state = pmp->end;
|
m_backup_state = pmp->end;
|
||||||
boost::re_detail::inplace_destroy(pmp);
|
boost::re_detail::inplace_destroy(pmp);
|
||||||
block_cache.put(condemmed);
|
put_mem_block(condemmed);
|
||||||
return true; // keep looking
|
return true; // keep looking
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,15 @@
|
|||||||
# include <malloc.h>
|
# include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3)
|
||||||
|
#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0
|
||||||
|
#include <new>
|
||||||
|
#else
|
||||||
|
#include <boost/regex/v4/mem_block_cache.hpp>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace boost{
|
namespace boost{
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -104,8 +113,34 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_regex_exception(const std::string&
|
|||||||
|
|
||||||
#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3)
|
#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3)
|
||||||
|
|
||||||
|
#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0
|
||||||
|
|
||||||
|
BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block()
|
||||||
|
{
|
||||||
|
return ::operator new(BOOST_REGEX_BLOCKSIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void* p)
|
||||||
|
{
|
||||||
|
::operator delete(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
mem_block_cache block_cache = { 0, };
|
mem_block_cache block_cache = { 0, };
|
||||||
|
|
||||||
|
BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block()
|
||||||
|
{
|
||||||
|
return block_cache.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void* p)
|
||||||
|
{
|
||||||
|
block_cache.put(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace re_detail
|
} // namespace re_detail
|
||||||
|
Reference in New Issue
Block a user