Skip to content

Commit

Permalink
Little tweaks to __PHYSFS_initSmallAlloc().
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Aug 14, 2017
1 parent 8db27a1 commit f425f05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/physfs.c
Expand Up @@ -3040,7 +3040,7 @@ int __PHYSFS_readAll(PHYSFS_Io *io, void *buf, const PHYSFS_uint64 len)
} /* __PHYSFS_readAll */


void *__PHYSFS_initSmallAlloc(void *ptr, PHYSFS_uint64 len)
void *__PHYSFS_initSmallAlloc(void *ptr, const size_t len)
{
void *useHeap = ((ptr == NULL) ? ((void *) 1) : ((void *) 0));
if (useHeap) /* too large for stack allocation or alloca() failed. */
Expand All @@ -3049,8 +3049,8 @@ void *__PHYSFS_initSmallAlloc(void *ptr, PHYSFS_uint64 len)
if (ptr != NULL)
{
void **retval = (void **) ptr;
/*printf("%s alloc'd (%d) bytes at (%p).\n",
useHeap ? "heap" : "stack", (int) len, ptr);*/
/*printf("%s alloc'd (%lld) bytes at (%p).\n",
useHeap ? "heap" : "stack", (long long) len, ptr);*/
*retval = useHeap;
return retval + 1;
} /* if */
Expand All @@ -3064,7 +3064,7 @@ void __PHYSFS_smallFree(void *ptr)
if (ptr != NULL)
{
void **block = ((void **) ptr) - 1;
const int useHeap = (*block != 0);
const int useHeap = (*block != NULL);
if (useHeap)
allocator.Free(block);
/*printf("%s free'd (%p).\n", useHeap ? "heap" : "stack", block);*/
Expand Down
2 changes: 1 addition & 1 deletion src/physfs_internal.h
Expand Up @@ -145,7 +145,7 @@ int __PHYSFS_ATOMIC_DECR(int *ptrval);
* NEVER forget to check for NULL...allocation can fail here, of course!
*/
#define __PHYSFS_SMALLALLOCTHRESHOLD 256
void *__PHYSFS_initSmallAlloc(void *ptr, PHYSFS_uint64 len);
void *__PHYSFS_initSmallAlloc(void *ptr, const size_t len);

#define __PHYSFS_smallAlloc(bytes) ( \
__PHYSFS_initSmallAlloc( \
Expand Down

0 comments on commit f425f05

Please sign in to comment.