Little tweaks to __PHYSFS_initSmallAlloc().
authorRyan C. Gordon <icculus@icculus.org>
Mon, 14 Aug 2017 13:57:57 -0400
changeset 1576 b25da658b8ee
parent 1575 be0a87101943
child 1577 77b9eee5b834
Little tweaks to __PHYSFS_initSmallAlloc().
src/physfs.c
src/physfs_internal.h
--- a/src/physfs.c	Mon Aug 14 11:43:18 2017 -0400
+++ b/src/physfs.c	Mon Aug 14 13:57:57 2017 -0400
@@ -3040,7 +3040,7 @@
 } /* __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. */
@@ -3049,8 +3049,8 @@
     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 */
@@ -3064,7 +3064,7 @@
     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);*/
--- a/src/physfs_internal.h	Mon Aug 14 11:43:18 2017 -0400
+++ b/src/physfs_internal.h	Mon Aug 14 13:57:57 2017 -0400
@@ -145,7 +145,7 @@
  * 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( \