forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpallocator.T
More file actions
56 lines (50 loc) · 1.83 KB
/
pallocator.T
File metadata and controls
56 lines (50 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file pallocator.T
* @author drose
* @date 2001-06-05
*/
template<class Type>
INLINE pallocator_single<Type>::
pallocator_single(TypeHandle type_handle) noexcept :
_type_handle(type_handle)
{
}
template<class Type>
INLINE Type *pallocator_single<Type>::
allocate(typename pallocator_single<Type>::size_type n, typename std::allocator<void>::const_pointer) {
TAU_PROFILE("pallocator_single:allocate()", " ", TAU_USER);
// This doesn't support allocating arrays.
assert(n == 1);
return (Type *)ASSUME_ALIGNED(StaticDeletedChain<Type>::allocate(sizeof(Type), _type_handle),
MEMORY_HOOK_ALIGNMENT);
}
template<class Type>
INLINE void pallocator_single<Type>::
deallocate(typename pallocator_single<Type>::pointer p, typename pallocator_single<Type>::size_type) {
TAU_PROFILE("pallocator_single:deallocate()", " ", TAU_USER);
StaticDeletedChain<Type>::deallocate(p, _type_handle);
}
template<class Type>
INLINE pallocator_array<Type>::
pallocator_array(TypeHandle type_handle) noexcept :
_type_handle(type_handle)
{
}
template<class Type>
INLINE Type *pallocator_array<Type>::
allocate(typename pallocator_array<Type>::size_type n, typename std::allocator<void>::const_pointer) {
return (typename pallocator_array<Type>::pointer)
ASSUME_ALIGNED(_type_handle.allocate_array(n * sizeof(Type)), MEMORY_HOOK_ALIGNMENT);
}
template<class Type>
INLINE void pallocator_array<Type>::
deallocate(typename pallocator_array<Type>::pointer p, typename pallocator_array<Type>::size_type) {
_type_handle.deallocate_array((void *)p);
}