Back to index

supertuxkart  0.5+dfsg1
Functions | Variables
btAlignedAllocator.cpp File Reference
#include "btAlignedAllocator.h"

Go to the source code of this file.

Functions

void * btAlignedAllocInternal (size_t size, int alignment)
 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
void btAlignedFreeInternal (void *ptr)

Variables

int gNumAlignedAllocs = 0
int gNumAlignedFree = 0
int gTotalBytesAlignedAllocs = 0

Function Documentation

void* btAlignedAllocInternal ( size_t  size,
int  alignment 
)

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

Definition at line 123 of file btAlignedAllocator.cpp.

{
 void *ret;
  char *real;
  unsigned long offset;
 
  gNumAlignedAllocs++;

  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 btAlignedFreeInternal ( void *  ptr)

Definition at line 142 of file btAlignedAllocator.cpp.

{

 void* real;
 gNumAlignedFree++;

  if (ptr) {
    real = *((void **)(ptr)-1);
    free(real);
  }
}

Variable Documentation

Definition at line 18 of file btAlignedAllocator.cpp.

int gNumAlignedFree = 0

Definition at line 19 of file btAlignedAllocator.cpp.

Definition at line 20 of file btAlignedAllocator.cpp.