Back to index

supertuxkart  0.5+dfsg1
Classes | Defines | Typedefs | Functions
btAlignedAllocator.h File Reference
#include "btScalar.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  btAlignedAllocator< T, Alignment >
struct  btAlignedAllocator< T, Alignment >::rebind< O >

Defines

#define btAlignedAlloc(a, b)   btAlignedAllocInternal(a,b)
#define btAlignedFree(ptr)   btAlignedFreeInternal(ptr)

Typedefs

typedef int size_type

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)

Define Documentation

#define btAlignedAlloc (   a,
 
)    btAlignedAllocInternal(a,b)

Definition at line 41 of file btAlignedAllocator.h.

#define btAlignedFree (   ptr)    btAlignedFreeInternal(ptr)

Definition at line 42 of file btAlignedAllocator.h.


Typedef Documentation

typedef int size_type

Definition at line 44 of file btAlignedAllocator.h.


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);
  }
}