4 * Hewlett-Packard Company
6 * Permission to use, copy, modify, distribute and sell this software
7 * and its documentation for any purpose is hereby granted without fee,
8 * provided that the above copyright notice appear in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation. Hewlett-Packard Company makes no
11 * representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
16 // Inclusion of this file is DEPRECATED. This is the original HP
17 // default allocator. It is provided only for backward compatibility.
18 // This file WILL BE REMOVED in a future release.
20 // DO NOT USE THIS FILE unless you have an old container implementation
21 // that requires an allocator with the HP-style interface.
23 // Standard-conforming allocators have a very different interface. The
24 // standard default allocator is declared in the header <memory>.
38 inline T
* allocate(ptrdiff_t size
, T
*) {
40 T
* tmp
= (T
*)(::operator new((size_t)(size
* sizeof(T
))));
42 cerr
<< "out of memory" << endl
;
50 inline void deallocate(T
* buffer
) {
51 ::operator delete(buffer
);
59 typedef const T
* const_pointer
;
61 typedef const T
& const_reference
;
62 typedef size_t size_type
;
63 typedef ptrdiff_t difference_type
;
64 pointer
allocate(size_type n
) {
65 return ::allocate((difference_type
)n
, (pointer
)0);
67 void deallocate(pointer p
) { ::deallocate(p
); }
68 pointer
address(reference x
) { return (pointer
)&x
; }
69 const_pointer
const_address(const_reference x
) {
70 return (const_pointer
)&x
;
72 size_type
init_page_size() {
73 return max(size_type(1), size_type(4096/sizeof(T
)));
75 size_type
max_size() const {
76 return max(size_type(1), size_type(UINT_MAX
/sizeof(T
)));
80 class allocator
<void> {
82 typedef void* pointer
;