1 /****************************************************************************
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
4 ** Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
6 ** This file is part of $PRODUCT$.
10 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 ****************************************************************************/
22 static rxx_allocator
<char> &allocator_instance ()
24 static rxx_allocator
<char>__allocator
;
35 static pp_fast_string
const *get (char const *__data
, std::size_t __size
)
38 char *data
= allocator_instance ().allocate (__size
+ 1);
39 memcpy(data
, __data
, __size
);
42 char *where
= allocator_instance ().allocate (sizeof (pp_fast_string
));
43 return new (where
) pp_fast_string (data
, __size
);
46 template <typename _InputIterator
>
47 static pp_fast_string
const *get (_InputIterator __first
, _InputIterator __last
)
50 std::ptrdiff_t __size
;
51 #if defined(__SUNPRO_CC)
52 std::distance (__first
, __last
, __size
);
54 __size
= std::distance (__first
, __last
);
56 assert (__size
>= 0 && __size
< 512);
58 char *data
= allocator_instance ().allocate (__size
+ 1);
59 std::copy (__first
, __last
, data
);
62 char *where
= allocator_instance ().allocate (sizeof (pp_fast_string
));
63 return new (where
) pp_fast_string (data
, __size
);
66 static pp_fast_string
const *get(std::string
const &__s
)
67 { return get (__s
.c_str (), __s
.size ()); }
74 // kate: space-indent on; indent-width 2; replace-tabs on;