added fix for heightfield (division by floating point scalar, instead of integer),

added default aligned alloc/free
This commit is contained in:
ejcoumans
2007-09-19 03:19:13 +00:00
parent 339917a9eb
commit 9fb6f0af09
2 changed files with 26 additions and 10 deletions

View File

@@ -54,17 +54,33 @@ void btAlignedFree (void* ptr)
}
#else
///todo
///will add some multi-platform version that works without _aligned_malloc/_aligned_free
void* btAlignedAlloc (int size, int alignment)
{
return new char[size];
void *ret;
char *real;
unsigned long offset;
real = (char *)malloc(size + sizeof(void *) + (alignment-1));
if (real) {
offset = (alignment - (unsigned long)(real + sizeof(void *))) & (alignment-1);
ret = (void *)((real + sizeof(void *)) + offset);
*((void **)(ret)-1) = (void *)(real);
} else {
ret = (void *)(real);
}
return (ret);
}
void btAlignedFree (void* ptr)
{
delete [] (char*) ptr;
void* real;
if (ptr) {
real = *((void **)(ptr)-1);
free(real);
}
}
#endif //