31 #ifndef RTABMAP_FLANN_ALLOCATOR_H_ 32 #define RTABMAP_FLANN_ALLOCATOR_H_ 51 T* mem = (
T*) ::malloc(
sizeof(
T)*count);
117 while (base !=
NULL) {
118 prev = *((
void**) base);
140 size = (size + (WORDSIZE - 1)) & ~(WORDSIZE - 1);
145 if (size > remaining) {
150 blocksize = (size +
sizeof(
void*) + (WORDSIZE-1) >
BLOCKSIZE) ?
151 size +
sizeof(
void*) + (WORDSIZE-1) : BLOCKSIZE;
154 void* m = ::malloc(blocksize);
156 fprintf(stderr,
"Failed to allocate memory.\n");
161 ((
void**) m)[0] =
base;
167 remaining = blocksize -
sizeof(
void*) - shift;
168 loc = ((
char*)m +
sizeof(
void*) + shift);
171 loc = (
char*)loc + size;
186 template <
typename T>
199 return allocator.allocateMemory(size) ;
202 #endif //FLANN_ALLOCATOR_H_
T * allocate(size_t count=1)
void * allocateMemory(int size)
T * allocate(size_t count=1)
PooledAllocator(int blocksize=BLOCKSIZE)