OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
spursAlignedAllocator.h
1// Gamespy Technology
2// NOTE: this code has been provided by Sony for usage in Speex SPURS Manager
3
4/*
5Bullet Continuous Collision Detection and Physics Library
6Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
7
8This software is provided 'as-is', without any express or implied warranty.
9In no event will the authors be held liable for any damages arising from the use of this software.
10Permission is granted to anyone to use this software for any purpose,
11including commercial applications, and to alter it and redistribute it freely,
12subject to the following restrictions:
13
141. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
152. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
163. This notice may not be removed or altered from any source distribution.
17*/
18
19#ifndef BT_ALIGNED_ALLOCATOR
20#define BT_ALIGNED_ALLOCATOR
21
25
26void* spursAlignedAlloc (int size, int alignment);
27
28void spursAlignedFree (void* ptr);
29
30
31typedef int size_type;
32
33
34template < typename T , unsigned Alignment >
35class spursAlignedAllocator {
36
37 typedef spursAlignedAllocator< T , Alignment > self_type;
38
39public:
40
41 //just going down a list:
42 spursAlignedAllocator() {}
43 /*
44 btAlignedAllocator( const self_type & ) {}
45 */
46
47 template < typename Other >
48 spursAlignedAllocator( const spursAlignedAllocator< Other , Alignment > & ) {}
49
50 typedef const T* const_pointer;
51 typedef const T& const_reference;
52 typedef T* pointer;
53 typedef T& reference;
54 typedef T value_type;
55
56 pointer address ( reference ref ) const { return &ref; }
57 const_pointer address ( const_reference ref ) const { return &ref; }
58 pointer allocate ( size_type n , const_pointer * hint = 0 ) {
59 (void)hint;
60 return reinterpret_cast< pointer >(spursAlignedAlloc( sizeof(value_type) * n , Alignment ));
61 }
62 void construct ( pointer ptr , const value_type & value ) { new (ptr) value_type( value ); }
63 void deallocate( pointer ptr ) {
64 spursAlignedFree( reinterpret_cast< void * >( ptr ) );
65 }
66 void destroy ( pointer ptr ) { ptr->~value_type(); }
67
68
69 template < typename O > struct rebind {
70 typedef spursAlignedAllocator< O , Alignment > other;
71 };
72 template < typename O >
73 self_type & operator=( const spursAlignedAllocator< O , Alignment > & ) { return *this; }
74
75 friend bool operator==( const self_type & , const self_type & ) { return true; }
76};
77
78
79
80#endif //BT_ALIGNED_ALLOCATOR
81
Definition spursAlignedAllocator.h:69