@@ -111,75 +111,4 @@ void MallocArrayAllocator<E>::free(E* addr) {
111
111
FreeHeap (addr);
112
112
}
113
113
114
- template <class E >
115
- bool ArrayAllocator<E>::should_use_malloc(size_t length) {
116
- return MallocArrayAllocator<E>::size_for (length) < ArrayAllocatorMallocLimit;
117
- }
118
-
119
- template <class E >
120
- E* ArrayAllocator<E>::allocate_malloc(size_t length, MEMFLAGS flags) {
121
- return MallocArrayAllocator<E>::allocate (length, flags);
122
- }
123
-
124
- template <class E >
125
- E* ArrayAllocator<E>::allocate_mmap(size_t length, MEMFLAGS flags) {
126
- return MmapArrayAllocator<E>::allocate (length, flags);
127
- }
128
-
129
- template <class E >
130
- E* ArrayAllocator<E>::allocate(size_t length, MEMFLAGS flags) {
131
- if (should_use_malloc (length)) {
132
- return allocate_malloc (length, flags);
133
- }
134
-
135
- return allocate_mmap (length, flags);
136
- }
137
-
138
- template <class E >
139
- E* ArrayAllocator<E>::reallocate_malloc(E* addr, size_t new_length, MEMFLAGS flags) {
140
- return MallocArrayAllocator<E>::reallocate (addr, new_length, flags);
141
- }
142
-
143
- template <class E >
144
- E* ArrayAllocator<E>::reallocate(E* old_addr, size_t old_length, size_t new_length, MEMFLAGS flags) {
145
- if (should_use_malloc (old_length) && should_use_malloc (new_length)) {
146
- return reallocate_malloc (old_addr, new_length, flags);
147
- }
148
-
149
- E* new_addr = (new_length > 0 )
150
- ? allocate (new_length, flags)
151
- : nullptr ;
152
-
153
- if (new_addr != nullptr && old_addr != nullptr ) {
154
- memcpy (new_addr, old_addr, MIN2 (old_length, new_length) * sizeof (E));
155
- }
156
-
157
- if (old_addr != nullptr ) {
158
- free (old_addr, old_length);
159
- }
160
-
161
- return new_addr;
162
- }
163
-
164
- template <class E >
165
- void ArrayAllocator<E>::free_malloc(E* addr, size_t length) {
166
- MallocArrayAllocator<E>::free (addr);
167
- }
168
-
169
- template <class E >
170
- void ArrayAllocator<E>::free_mmap(E* addr, size_t length) {
171
- MmapArrayAllocator<E>::free (addr, length);
172
- }
173
-
174
- template <class E >
175
- void ArrayAllocator<E>::free(E* addr, size_t length) {
176
- if (addr != nullptr ) {
177
- if (should_use_malloc (length)) {
178
- free_malloc (addr, length);
179
- } else {
180
- free_mmap (addr, length);
181
- }
182
- }
183
- }
184
-
185
114
#endif // SHARE_MEMORY_ALLOCATION_INLINE_HPP
0 commit comments