mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-29 19:55:28 +08:00
bb84e66919
* Makefile.in (install): Some of HEADERS come from the stl dir now. * algorithm, deque, functional, iterator, list, map, memory, numeric, queue, set, stack, utility, vector: Now in stl dir. stl/: * algo.h, algobase.h, alloc.h, bvector.h, defalloc.h, deque.h, function.h, hash_map.h, hash_set.h, hashtable.h, heap.h, iterator.h, list.h, map.h, multimap.h, multiset.h, pair.h, pthread_alloc.h, rope.h, ropeimpl.h, set.h, slist.h, stack.h, stl_config.h, tempbuf.h, tree.h, type_traits.h, vector.h: Update to October 27 SGI snapshot. * algorithm, deque, functional, hash_map, hash_set, iterator, list, map, memory, numeric, pthread_alloc, queue, rope, set, slist, stack, stl_algo.h, stl_algobase.h, stl_alloc.h, stl_bvector.h, stl_construct.h, stl_deque.h, stl_function.h, stl_hash_fun.h, stl_hash_map.h, stl_hash_set.h, stl_hashtable.h, stl_heap.h, stl_iterator.h, stl_list.h, stl_map.h, stl_multimap.h, stl_multiset.h, stl_numeric.h, stl_pair.h, stl_queue.h, stl_raw_storage_iter.h, stl_relops.h, stl_rope.h, stl_set.h, stl_slist.h, stl_stack.h, stl_tempbuf.h, stl_tree.h, stl_uninitialized.h, stl_vector.h, utility, vector: New files in October 27 SGI snapshot. From-SVN: r16277
87 lines
2.3 KiB
C++
87 lines
2.3 KiB
C++
/*
|
|
*
|
|
* Copyright (c) 1994
|
|
* Hewlett-Packard Company
|
|
*
|
|
* Permission to use, copy, modify, distribute and sell this software
|
|
* and its documentation for any purpose is hereby granted without fee,
|
|
* provided that the above copyright notice appear in all copies and
|
|
* that both that copyright notice and this permission notice appear
|
|
* in supporting documentation. Hewlett-Packard Company makes no
|
|
* representations about the suitability of this software for any
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
|
*
|
|
*/
|
|
|
|
// Inclusion of this file is DEPRECATED. This is the original HP
|
|
// default allocator. It is provided only for backward compatibility.
|
|
//
|
|
// DO NOT USE THIS FILE unless you have an old container implementation
|
|
// that requires an allocator with the HP-style interface. SGI STL
|
|
// uses a different allocator interface. SGI-style allocators are not
|
|
// parametrized with respect to the object type; they traffic in void *
|
|
// pointers. This file is not included by any other SGI STL header.
|
|
|
|
#ifndef DEFALLOC_H
|
|
#define DEFALLOC_H
|
|
|
|
#include <new.h>
|
|
#include <stddef.h>
|
|
#include <stdlib.h>
|
|
#include <limits.h>
|
|
#include <iostream.h>
|
|
#include <algobase.h>
|
|
|
|
|
|
template <class T>
|
|
inline T* allocate(ptrdiff_t size, T*) {
|
|
set_new_handler(0);
|
|
T* tmp = (T*)(::operator new((size_t)(size * sizeof(T))));
|
|
if (tmp == 0) {
|
|
cerr << "out of memory" << endl;
|
|
exit(1);
|
|
}
|
|
return tmp;
|
|
}
|
|
|
|
|
|
template <class T>
|
|
inline void deallocate(T* buffer) {
|
|
::operator delete(buffer);
|
|
}
|
|
|
|
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 size_t size_type;
|
|
typedef ptrdiff_t difference_type;
|
|
pointer allocate(size_type n) {
|
|
return ::allocate((difference_type)n, (pointer)0);
|
|
}
|
|
void deallocate(pointer p) { ::deallocate(p); }
|
|
pointer address(reference x) { return (pointer)&x; }
|
|
const_pointer const_address(const_reference x) {
|
|
return (const_pointer)&x;
|
|
}
|
|
size_type init_page_size() {
|
|
return max(size_type(1), size_type(4096/sizeof(T)));
|
|
}
|
|
size_type max_size() const {
|
|
return max(size_type(1), size_type(UINT_MAX/sizeof(T)));
|
|
}
|
|
};
|
|
|
|
class allocator<void> {
|
|
public:
|
|
typedef void* pointer;
|
|
};
|
|
|
|
|
|
|
|
#endif
|