Kaydet (Commit) c6e0325d authored tarafından Herbert Dürr's avatar Herbert Dürr

#i124896# remove obsoleted sal-module-internal custom STL allocator

The SAL module avoided the heavy dependency on the stlport4-libraries by using
a custom allocator for its internal STL containers. With stlport4 removed these
dependencies are gone and the SAL-internal custom allocator is obsoleted. Since
the custom allocator results in build problems with clang>=3.4 or xcode>=5.1 it
is time to remove it for good.
üst d3ebac9e
...@@ -23,21 +23,10 @@ ...@@ -23,21 +23,10 @@
#if ! defined(OSL_DIAGNOSE_HXX_INCLUDED) #if ! defined(OSL_DIAGNOSE_HXX_INCLUDED)
#define OSL_DIAGNOSE_HXX_INCLUDED #define OSL_DIAGNOSE_HXX_INCLUDED
#if ! defined(_OSL_DIAGNOSE_H_)
#include "osl/diagnose.h" #include "osl/diagnose.h"
#endif
#if ! defined(_OSL_INTERLOCK_H_)
#include "osl/interlck.h" #include "osl/interlck.h"
#endif
#if ! defined(_OSL_MUTEX_HXX_)
#include "osl/mutex.hxx" #include "osl/mutex.hxx"
#endif
#if ! defined(INCLUDED_RTL_ALLOCATOR_HXX)
#include "rtl/allocator.hxx"
#endif
#if ! defined(_RTL_INSTANCE_HXX_)
#include "rtl/instance.hxx" #include "rtl/instance.hxx"
#endif
#include <hash_set> #include <hash_set>
#include <functional> #include <functional>
#include <typeinfo> #include <typeinfo>
...@@ -91,8 +80,7 @@ struct VoidPtrHash : ::std::unary_function<void const*, ::std::size_t> { ...@@ -91,8 +80,7 @@ struct VoidPtrHash : ::std::unary_function<void const*, ::std::size_t> {
} }
}; };
typedef ::std::hash_set<void const*, VoidPtrHash, ::std::equal_to<void const*>, typedef ::std::hash_set<void const*, VoidPtrHash, ::std::equal_to<void const*> > VoidPointerSet;
::rtl::Allocator<void const*> > VoidPointerSet;
struct ObjectRegistryData { struct ObjectRegistryData {
ObjectRegistryData( ::std::type_info const& rTypeInfo ) ObjectRegistryData( ::std::type_info const& rTypeInfo )
......
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#if !defined INCLUDED_RTL_ALLOCATOR_HXX
#define INCLUDED_RTL_ALLOCATOR_HXX
#if ! defined(_SAL_TYPES_H_)
#include "sal/types.h"
#endif
#if ! defined(_RTL_ALLOC_H_)
#include "rtl/alloc.h"
#endif
#include <cstddef>
//######################################################
// This is no general purpose STL allocator but one
// necessary to use STL for some implementation but
// avoid linking sal against the STLPort library!!!
// For more information on when and how to define a
// custom stl allocator have a look at Scott Meyers:
// "Effective STL", Nicolai M. Josuttis:
// "The C++ Standard Library - A Tutorial and Reference"
// and at http://www.josuttis.com/cppcode/allocator.html
namespace rtl {
/** @internal */
template<class T>
class Allocator
{
public:
typedef T value_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef ::std::size_t size_type;
typedef ::std::ptrdiff_t difference_type;
//-----------------------------------------
template<class U>
struct rebind
{
typedef Allocator<U> other;
};
//-----------------------------------------
pointer address (reference value) const
{
return &value;
}
//-----------------------------------------
const_pointer address (const_reference value) const
{
return &value;
}
//-----------------------------------------
Allocator() SAL_THROW(())
{}
//-----------------------------------------
template<class U>
Allocator (const Allocator<U>&) SAL_THROW(())
{}
//-----------------------------------------
Allocator(const Allocator&) SAL_THROW(())
{}
//-----------------------------------------
~Allocator() SAL_THROW(())
{}
//-----------------------------------------
size_type max_size() const SAL_THROW(())
{
return size_type(-1)/sizeof(T);
}
//-----------------------------------------
/* Normally the code for allocate should
throw a std::bad_alloc exception if the
requested memory could not be allocated:
(C++ standard 20.4.1.1):
pointer allocate (size_type n, const void* hint = 0)
{
pointer p = reinterpret_cast<pointer>(
rtl_allocateMemory(sal_uInt32(n * sizeof(T))));
if (NULL == p)
throw ::std::bad_alloc();
return p;
}
but some compilers do not compile it if exceptions
are not enabled, e.g. GCC under Linux and it is
in general not desired to compile sal with exceptions
enabled. */
pointer allocate (size_type n, const void* hint = 0)
{
hint = hint; /* avoid warnings */
return reinterpret_cast<pointer>(
rtl_allocateMemory(sal_uInt32(n * sizeof(T))));
}
//-----------------------------------------
void deallocate (pointer p, size_type /* n */)
{
rtl_freeMemory(p);
}
//-----------------------------------------
void construct (pointer p, const T& value)
{
new ((void*)p)T(value);
}
//-----------------------------------------
void destroy (pointer p)
{
p->~T();
}
};
//######################################################
// Custom STL allocators must be stateless (see
// references above) that's why the operators below
// return always true or false
/** @internal */
template<class T, class U>
inline bool operator== (const Allocator<T>&, const Allocator<U>&) SAL_THROW(())
{
return true;
}
/** @internal */
template<class T, class U>
inline bool operator!= (const Allocator<T>&, const Allocator<U>&) SAL_THROW(())
{
return false;
}
} /* namespace rtl */
#endif /* INCLUDED_RTL_ALLOCATOR_HXX */
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
namespace { namespace {
typedef std::vector<rtl::OString, rtl::Allocator<rtl::OString> > OStringVec; typedef std::vector<rtl::OString> OStringVec;
struct StaticDebugBaseAddressFilter struct StaticDebugBaseAddressFilter
: rtl::StaticWithInit<OStringVec const, StaticDebugBaseAddressFilter> { : rtl::StaticWithInit<OStringVec const, StaticDebugBaseAddressFilter> {
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "path_helper.h" #include "path_helper.h"
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <rtl/allocator.hxx>
namespace osl namespace osl
{ {
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include "secimpl.h" #include "secimpl.h"
#include "rtl/allocator.hxx"
#include <osl/file.hxx> #include <osl/file.hxx>
#include <list> #include <list>
...@@ -63,11 +62,11 @@ const rtl::OUString QUOTE = rtl::OUString::createFromAscii("\""); ...@@ -63,11 +62,11 @@ const rtl::OUString QUOTE = rtl::OUString::createFromAscii("\"");
namespace /* private */ namespace /* private */
{ {
//################################################# //#################################################
typedef std::list<rtl::OUString, rtl::Allocator<rtl::OUString> > string_container_t; typedef std::list<rtl::OUString> string_container_t;
typedef string_container_t::iterator string_container_iterator_t; typedef string_container_t::iterator string_container_iterator_t;
typedef string_container_t::const_iterator string_container_const_iterator_t; typedef string_container_t::const_iterator string_container_const_iterator_t;
typedef std::pair<string_container_iterator_t, string_container_iterator_t> iterator_pair_t; typedef std::pair<string_container_iterator_t, string_container_iterator_t> iterator_pair_t;
typedef std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > environment_container_t; typedef std::vector<sal_Unicode > environment_container_t;
//################################################# //#################################################
/* Function object that compares two strings that are /* Function object that compares two strings that are
...@@ -307,7 +306,7 @@ namespace /* private */ ...@@ -307,7 +306,7 @@ namespace /* private */
rtl::OUString ret(path); rtl::OUString ret(path);
if (path.getLength() > 260) if (path.getLength() > 260)
{ {
std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec(path.getLength() + 1); std::vector<sal_Unicode> vec(path.getLength() + 1);
//GetShortPathNameW only works if the file can be found! //GetShortPathNameW only works if the file can be found!
const DWORD len = GetShortPathNameW( const DWORD len = GetShortPathNameW(
reinterpret_cast<LPCWSTR>(path.getStr()), reinterpret_cast<LPWSTR>(&vec[0]), path.getLength() + 1); reinterpret_cast<LPCWSTR>(path.getStr()), reinterpret_cast<LPWSTR>(&vec[0]), path.getLength() + 1);
...@@ -316,8 +315,7 @@ namespace /* private */ ...@@ -316,8 +315,7 @@ namespace /* private */
&& extension.getLength()) && extension.getLength())
{ {
const rtl::OUString extPath(path + extension); const rtl::OUString extPath(path + extension);
std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec2( std::vector<sal_Unicode > vec2( extPath.getLength() + 1);
extPath.getLength() + 1);
const DWORD len2 = GetShortPathNameW( const DWORD len2 = GetShortPathNameW(
reinterpret_cast<LPCWSTR>(extPath.getStr()), reinterpret_cast<LPWSTR>(&vec2[0]), extPath.getLength() + 1); reinterpret_cast<LPCWSTR>(extPath.getStr()), reinterpret_cast<LPWSTR>(&vec2[0]), extPath.getLength() + 1);
ret = rtl::OUString(&vec2[0], len2); ret = rtl::OUString(&vec2[0], len2);
......
...@@ -44,8 +44,6 @@ ...@@ -44,8 +44,6 @@
#include <tools/postwin.h> #include <tools/postwin.h>
#endif #endif
#include "rtl/allocator.hxx"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <vector> #include <vector>
...@@ -296,7 +294,7 @@ public: ...@@ -296,7 +294,7 @@ public:
//######################################################### //#########################################################
typedef std::vector<std::string, rtl::Allocator<std::string> > string_container_t; typedef std::vector<std::string> string_container_t;
typedef string_container_t::const_iterator string_container_const_iter_t; typedef string_container_t::const_iterator string_container_const_iter_t;
typedef string_container_t::iterator string_container_iter_t; typedef string_container_t::iterator string_container_iter_t;
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include <rtl/instance.hxx> #include <rtl/instance.hxx>
#include <rtl/malformeduriexception.hxx> #include <rtl/malformeduriexception.hxx>
#include <rtl/uri.hxx> #include <rtl/uri.hxx>
#include "rtl/allocator.hxx"
#include "macro.hxx" #include "macro.hxx"
...@@ -134,10 +133,7 @@ struct rtl_bootstrap_NameValue ...@@ -134,10 +133,7 @@ struct rtl_bootstrap_NameValue
{} {}
}; };
typedef std::list< typedef std::list<rtl_bootstrap_NameValue> NameValueList;
rtl_bootstrap_NameValue,
rtl::Allocator< rtl_bootstrap_NameValue >
> NameValueList;
bool find( bool find(
NameValueList const & list, rtl::OUString const & key, NameValueList const & list, rtl::OUString const & key,
...@@ -605,10 +601,7 @@ void Bootstrap_Impl::expandValue( ...@@ -605,10 +601,7 @@ void Bootstrap_Impl::expandValue(
namespace { namespace {
struct bootstrap_map { struct bootstrap_map {
typedef std::hash_map< typedef std::hash_map< const rtl::OUString, Bootstrap_Impl*, rtl::OUStringHash > t;
rtl::OUString, Bootstrap_Impl *,
rtl::OUStringHash, std::equal_to< rtl::OUString >,
rtl::Allocator< OUString > > t;
// get and release must only be called properly synchronized via some mutex // get and release must only be called properly synchronized via some mutex
// (e.g., osl::Mutex::getGlobalMutex()): // (e.g., osl::Mutex::getGlobalMutex()):
......
...@@ -23,12 +23,10 @@ ...@@ -23,12 +23,10 @@
// MARKER(update_precomp.py): autogen include statement, do not remove // MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sal.hxx" #include "precompiled_sal.hxx"
#include "rtl/allocator.hxx"
#include "hash.h" #include "hash.h"
#include "strimp.h" #include "strimp.h"
#include <hash_set> #include <hash_set>
namespace { namespace {
...@@ -53,8 +51,7 @@ struct UStringEqual ...@@ -53,8 +51,7 @@ struct UStringEqual
} }
}; };
typedef std::hash_set< rtl_uString *, UStringHash, UStringEqual, typedef std::hash_set< rtl_uString *, UStringHash, UStringEqual > StringHashTable;
rtl::Allocator<rtl_uString *> > StringHashTable;
StringHashTable * StringHashTable *
getHashTable () getHashTable ()
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <hash_map> #include <hash_map>
#include "rtl/allocator.hxx"
#include <functional> #include <functional>
#include <list> #include <list>
...@@ -153,11 +152,10 @@ struct hashModule ...@@ -153,11 +152,10 @@ struct hashModule
}; };
typedef std::hash_map< typedef std::hash_map<
oslModule, const oslModule,
std::pair<sal_uInt32, component_canUnloadFunc>, std::pair<sal_uInt32, component_canUnloadFunc>,
hashModule, hashModule,
std::equal_to<oslModule>, std::equal_to<oslModule>
rtl::Allocator<oslModule>
> ModuleMap; > ModuleMap;
typedef ModuleMap::iterator Mod_IT; typedef ModuleMap::iterator Mod_IT;
...@@ -243,7 +241,7 @@ extern "C" void SAL_CALL rtl_unloadUnusedModules( TimeValue* libUnused) ...@@ -243,7 +241,7 @@ extern "C" void SAL_CALL rtl_unloadUnusedModules( TimeValue* libUnused)
{ {
MutexGuard guard( getUnloadingMutex()); MutexGuard guard( getUnloadingMutex());
typedef std::list< oslModule, rtl::Allocator<oslModule> > list_type; typedef std::list< oslModule > list_type;
list_type unloadedModulesList; list_type unloadedModulesList;
ModuleMap& moduleMap= getModuleMap(); ModuleMap& moduleMap= getModuleMap();
...@@ -302,11 +300,10 @@ struct hashListener ...@@ -302,11 +300,10 @@ struct hashListener
}; };
typedef std::hash_map< typedef std::hash_map<
sal_Int32, const sal_Int32,
std::pair<rtl_unloadingListenerFunc, void*>, std::pair<rtl_unloadingListenerFunc, void*>,
hashListener, hashListener,
std::equal_to<sal_Int32>, std::equal_to<sal_Int32>
rtl::Allocator<sal_Int32>
> ListenerMap; > ListenerMap;
typedef ListenerMap::iterator Lis_IT; typedef ListenerMap::iterator Lis_IT;
...@@ -333,10 +330,7 @@ static ListenerMap& getListenerMap() ...@@ -333,10 +330,7 @@ static ListenerMap& getListenerMap()
// available. Otherwise a new cookie will be provided. // available. Otherwise a new cookie will be provided.
// not a new value is returned. // not a new value is returned.
typedef std::deque< typedef std::deque< sal_Int32 > queue_type;
sal_Int32,
rtl::Allocator<sal_Int32>
> queue_type;
static queue_type& getCookieQueue() static queue_type& getCookieQueue()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment