Exemplo n.º 1
0
void*	btAlignedAllocInternal	(size_t size, int alignment)
{
	gNumAlignedAllocs++;
	void* ptr;
	ptr = sAlignedAllocFunc(size, alignment);
//	printf("btAlignedAllocInternal %d, %x\n",size,ptr);
	return ptr;
}
void*	btAlignedAllocInternal	(size_t size, int alignment)
{
	gNumAlignedAllocs++;
  void* ptr;
#if defined (BT_HAS_ALIGNED_ALLOCATOR) || defined(__CELLOS_LV2__)
	ptr = sAlignedAllocFunc(size, alignment);
#else
  char *real;
  unsigned long offset;

  real = (char *)sAllocFunc(size + sizeof(void *) + (alignment-1));
  if (real) {
    offset = (alignment - (unsigned long)(real + sizeof(void *))) & (alignment-1);
    ptr = (void *)((real + sizeof(void *)) + offset);
    *((void **)(ptr)-1) = (void *)(real);
  } else {
    ptr = (void *)(real);
  }
#endif  // defined (BT_HAS_ALIGNED_ALLOCATOR) || defined(__CELLOS_LV2__)
//	printf("btAlignedAllocInternal %d, %x\n",size,ptr);
	return ptr;
}