From b51965dddbed68f23c5e8c169c23c794313ce5f6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 28 Jun 2011 17:17:23 +0200 Subject: Add boost subset as an implementation detail --- cutl/details/boost/regex/src/regex_raw_buffer.cxx | 70 +++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 cutl/details/boost/regex/src/regex_raw_buffer.cxx (limited to 'cutl/details/boost/regex/src/regex_raw_buffer.cxx') diff --git a/cutl/details/boost/regex/src/regex_raw_buffer.cxx b/cutl/details/boost/regex/src/regex_raw_buffer.cxx new file mode 100644 index 0000000..a0c4811 --- /dev/null +++ b/cutl/details/boost/regex/src/regex_raw_buffer.cxx @@ -0,0 +1,70 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_raw_buffer.cpp + * VERSION see + * DESCRIPTION: Member functions for class raw_storage. + */ + + +#define BOOST_REGEX_SOURCE +#include +#include +#include +#include + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::memcpy; + using ::memmove; +} +#endif + + +namespace cutl_details_boost{ namespace re_detail{ + +void BOOST_REGEX_CALL raw_storage::resize(size_type n) +{ + register size_type newsize = start ? last - start : 1024; + while(newsize < n) + newsize *= 2; + register size_type datasize = end - start; + // extend newsize to WORD/DWORD boundary: + newsize = (newsize + padding_mask) & ~(padding_mask); + + // allocate and copy data: + register pointer ptr = static_cast(::operator new(newsize)); + BOOST_REGEX_NOEH_ASSERT(ptr) + std::memcpy(ptr, start, datasize); + + // get rid of old buffer: + ::operator delete(start); + + // and set up pointers: + start = ptr; + end = ptr + datasize; + last = ptr + newsize; +} + +void* BOOST_REGEX_CALL raw_storage::insert(size_type pos, size_type n) +{ + BOOST_ASSERT(pos <= size_type(end - start)); + if(size_type(last - end) < n) + resize(n + (end - start)); + register void* result = start + pos; + std::memmove(start + pos + n, start + pos, (end - start) - pos); + end += n; + return result; +} + +}} // namespaces -- cgit v1.1