Skip to content
Permalink
Browse files
Align smallAllocs to the native pointer size.
  • Loading branch information
icculus committed Mar 10, 2012
1 parent a0b21c9 commit 9dceda3d9f930f87b9946dbf7aa37d572645bb64
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/physfs.c
@@ -2748,17 +2748,17 @@ static void setDefaultAllocator(void)

void *__PHYSFS_initSmallAlloc(void *ptr, PHYSFS_uint64 len)
{
const char useHeap = ((ptr == NULL) ? 1 : 0);
void *useHeap = ((ptr == NULL) ? ((void *) 1) : ((void *) 0));
if (useHeap) /* too large for stack allocation or alloca() failed. */
ptr = allocator.Malloc(len+1);
ptr = allocator.Malloc(len+sizeof (void *));

if (ptr != NULL)
{
char *retval = (char *) ptr;
void **retval = (void **) ptr;
/*printf("%s alloc'd (%d) bytes at (%p).\n",
useHeap ? "heap" : "stack", (int) len, ptr);*/
*retval = useHeap;
return (retval + 1);
return retval + 1;
} /* if */

return NULL; /* allocation failed. */
@@ -2769,8 +2769,8 @@ void __PHYSFS_smallFree(void *ptr)
{
if (ptr != NULL)
{
char *block = ((char *) ptr) - 1;
const char useHeap = *block;
void **block = ((void **) ptr) - 1;
const int useHeap = (*block != 0);
if (useHeap)
allocator.Free(block);
/*printf("%s free'd (%p).\n", useHeap ? "heap" : "stack", block);*/

0 comments on commit 9dceda3

Please sign in to comment.