multi-platform issues with allocator

This commit is contained in:
ejcoumans
2006-12-06 04:51:13 +00:00
parent bf591b44ec
commit 5a5ba572a7
3 changed files with 59 additions and 6 deletions

View File

@@ -19,7 +19,13 @@ subject to the following restrictions:
///we probably replace this with our own aligned memory allocator
///so we replace _aligned_malloc and _aligned_free with our own
///that is better portable and more predictable
#include <malloc.h>
#include "btScalar.h"
void* btAlignedAlloc (int size, int alignment);
void btAlignedFree (void* ptr);
typedef int size_type;
@@ -47,11 +53,11 @@ public:
pointer address ( reference ref ) const { return &ref; }
const_pointer address ( const_reference ref ) const { return &ref; }
pointer allocate ( size_type n , const_pointer * hint = 0 ) {
return reinterpret_cast< pointer >(_aligned_malloc( sizeof(value_type) * n , Alignment ));
return reinterpret_cast< pointer >(btAlignedAlloc( sizeof(value_type) * n , Alignment ));
}
void construct ( pointer ptr , const value_type & value ) { new (ptr) value_type( value ); }
void deallocate( pointer ptr ) {
_aligned_free( reinterpret_cast< void * >( ptr ) );
btAlignedFree( reinterpret_cast< void * >( ptr ) );
}
void destroy ( pointer ptr ) { ptr->~value_type(); }