more fixes for new Linux gcc
This commit is contained in:
parent
c5e2eefa80
commit
f5e92eec6c
|
|
@ -16,13 +16,13 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef OLD_STYLE_ALLOCATOR
|
||||
#if defined(OLD_STYLE_ALLOCATOR)
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<class Type>
|
||||
INLINE void *dallocator<Type>::
|
||||
INLINE Type *dallocator<Type>::
|
||||
allocate(size_t n) {
|
||||
return default_operator_new(n);
|
||||
return (Type *)default_operator_new(n);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
|
|
@ -32,7 +32,34 @@ deallocate(void *p, size_t) {
|
|||
}
|
||||
#endif // NDEBUG
|
||||
|
||||
#else // OLD_STYLE_ALLOCATOR
|
||||
#elif defined(GNU_STYLE_ALLOCATOR)
|
||||
|
||||
template<class Type>
|
||||
INLINE dallocator<Type>::
|
||||
dallocator() {
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
template<class _Tp1>
|
||||
INLINE dallocator<Type>::
|
||||
dallocator(const dallocator<_Tp1> &) {
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<class Type>
|
||||
INLINE Type *dallocator<Type>::
|
||||
allocate(size_t n) {
|
||||
return (Type *)default_operator_new(n * sizeof(Type));
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
INLINE void dallocator<Type>::
|
||||
deallocate(void *p, size_t) {
|
||||
default_operator_delete(p);
|
||||
}
|
||||
#endif // NDEBUG
|
||||
|
||||
#else // *_STYLE_ALLOCATOR
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<class Type>
|
||||
|
|
@ -49,4 +76,4 @@ deallocate(void *p, allocator<Type>::size_type) {
|
|||
}
|
||||
#endif // NDEBUG
|
||||
|
||||
#endif // OLD_STYLE_ALLOCATOR
|
||||
#endif // *_STYLE_ALLOCATOR
|
||||
|
|
|
|||
|
|
@ -36,21 +36,45 @@
|
|||
// within the MemoryUsage class itself.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef OLD_STYLE_ALLOCATOR
|
||||
// Early versions of gcc used its own kind of allocator, somewhat
|
||||
// different from the STL standard.
|
||||
#if defined(OLD_STYLE_ALLOCATOR)
|
||||
// Early versions of gcc wanted to use its own kind of allocator,
|
||||
// somewhat different from the STL standard. Irix uses this one too.
|
||||
// It might be inherited from an early draft of the STL standard.
|
||||
|
||||
template<class Type>
|
||||
class dallocator : public alloc {
|
||||
public:
|
||||
#ifndef NDEBUG
|
||||
static void *allocate(size_t n);
|
||||
static void deallocate(void *p, size_t n);
|
||||
INLINE static Type *allocate(size_t n);
|
||||
INLINE static void deallocate(void *p, size_t n);
|
||||
#endif // NDEBUG
|
||||
};
|
||||
|
||||
#else // OLD_STYLE_ALLOCATOR
|
||||
#elif defined(GNU_STYLE_ALLOCATOR)
|
||||
// Later versions of gcc want to use a still different, nonstandard
|
||||
// definition. Sheesh.
|
||||
|
||||
template<class Type>
|
||||
class dallocator : public allocator<Type> {
|
||||
public:
|
||||
INLINE dallocator();
|
||||
template<class _Tp1>
|
||||
INLINE dallocator(const dallocator<_Tp1> &other);
|
||||
|
||||
#ifndef NDEBUG
|
||||
INLINE Type *allocate(size_t n);
|
||||
INLINE void deallocate(void *p, size_t n);
|
||||
#endif // NDEBUG
|
||||
|
||||
template <class _Tp1> struct rebind {
|
||||
typedef dallocator<_Tp1> other;
|
||||
};
|
||||
};
|
||||
|
||||
#else // *_STYLE_ALLOCATOR
|
||||
|
||||
// This is the correct allocator declaration as the current C++
|
||||
// standard defines it.
|
||||
template<class Type>
|
||||
class dallocator : public allocator<Type> {
|
||||
public:
|
||||
|
|
@ -60,7 +84,7 @@ public:
|
|||
INLINE void deallocate(void *p, size_type n);
|
||||
#endif // NDEBUG
|
||||
};
|
||||
#endif // OLD_STYLE_ALLOCATOR
|
||||
#endif // *_STYLE_ALLOCATOR
|
||||
|
||||
#include "dallocator.T"
|
||||
|
||||
|
|
|
|||
|
|
@ -34,11 +34,22 @@ deallocate(void *p, size_t) {
|
|||
|
||||
#elif defined(GNU_STYLE_ALLOCATOR)
|
||||
|
||||
template<class Type>
|
||||
INLINE pallocator<Type>::
|
||||
pallocator() {
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
template<class _Tp1>
|
||||
INLINE pallocator<Type>::
|
||||
pallocator(const pallocator<_Tp1> &) {
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<class Type>
|
||||
INLINE Type *pallocator<Type>::
|
||||
allocate(size_t n) {
|
||||
return (Type *)(*global_operator_new)(n);
|
||||
return (Type *)(*global_operator_new)(n * sizeof(Type));
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ public:
|
|||
template<class Type>
|
||||
class pallocator : public allocator<Type> {
|
||||
public:
|
||||
INLINE pallocator();
|
||||
template<class _Tp1>
|
||||
INLINE pallocator(const pallocator<_Tp1> &other);
|
||||
|
||||
#ifndef NDEBUG
|
||||
INLINE Type *allocate(size_t n);
|
||||
INLINE void deallocate(void *p, size_t n);
|
||||
|
|
@ -77,14 +81,6 @@ public:
|
|||
// INLINE void deallocate(pointer p, size_type n);
|
||||
INLINE void deallocate(void *p, size_type n);
|
||||
#endif // NDEBUG
|
||||
|
||||
#ifdef __GNUC__
|
||||
// Some versions of the gcc library require this structure to be
|
||||
// declared. I don't know what it's all about.
|
||||
template <class _Tp1> struct rebind {
|
||||
typedef pallocator<_Tp1> other;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
#endif // *_STYLE_ALLOCATOR
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue