Moved some functions around.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 25 Mar 2012 16:15:10 -0400
changeset 1279 5fc8dff2909b
parent 1278 570b476e0230
child 1280 bd174b99fa5b
Moved some functions around. We want the #undef malloc, etc, lines as close to the end of the file as possible, and __PHYSFS_readAll() not in the middle of the allocator code.
src/physfs.c
--- a/src/physfs.c	Sun Mar 25 16:13:23 2012 -0400
+++ b/src/physfs.c	Sun Mar 25 16:15:10 2012 -0400
@@ -2644,6 +2644,44 @@
 } /* PHYSFS_stat */
 
 
+int __PHYSFS_readAll(PHYSFS_Io *io, void *buf, const PHYSFS_uint64 len)
+{
+    return (io->read(io, buf, len) == len);
+} /* __PHYSFS_readAll */
+
+
+void *__PHYSFS_initSmallAlloc(void *ptr, PHYSFS_uint64 len)
+{
+    void *useHeap = ((ptr == NULL) ? ((void *) 1) : ((void *) 0));
+    if (useHeap)  /* too large for stack allocation or alloca() failed. */
+        ptr = allocator.Malloc(len+sizeof (void *));
+
+    if (ptr != NULL)
+    {
+        void **retval = (void **) ptr;
+        /*printf("%s alloc'd (%d) bytes at (%p).\n",
+                useHeap ? "heap" : "stack", (int) len, ptr);*/
+        *retval = useHeap;
+        return retval + 1;
+    } /* if */
+
+    return NULL;  /* allocation failed. */
+} /* __PHYSFS_initSmallAlloc */
+
+
+void __PHYSFS_smallFree(void *ptr)
+{
+    if (ptr != NULL)
+    {
+        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);*/
+    } /* if */
+} /* __PHYSFS_smallFree */
+
+
 int PHYSFS_setAllocator(const PHYSFS_Allocator *a)
 {
     BAIL_IF_MACRO(initialized, PHYSFS_ERR_IS_INITIALIZED, 0);
@@ -2700,43 +2738,5 @@
     } /* if */
 } /* setDefaultAllocator */
 
-
-void *__PHYSFS_initSmallAlloc(void *ptr, PHYSFS_uint64 len)
-{
-    void *useHeap = ((ptr == NULL) ? ((void *) 1) : ((void *) 0));
-    if (useHeap)  /* too large for stack allocation or alloca() failed. */
-        ptr = allocator.Malloc(len+sizeof (void *));
-
-    if (ptr != NULL)
-    {
-        void **retval = (void **) ptr;
-        /*printf("%s alloc'd (%d) bytes at (%p).\n",
-                useHeap ? "heap" : "stack", (int) len, ptr);*/
-        *retval = useHeap;
-        return retval + 1;
-    } /* if */
-
-    return NULL;  /* allocation failed. */
-} /* __PHYSFS_initSmallAlloc */
-
-
-void __PHYSFS_smallFree(void *ptr)
-{
-    if (ptr != NULL)
-    {
-        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);*/
-    } /* if */
-} /* __PHYSFS_smallFree */
-
-
-int __PHYSFS_readAll(PHYSFS_Io *io, void *buf, const PHYSFS_uint64 len)
-{
-    return (io->read(io, buf, len) == len);
-} /* __PHYSFS_readAll */
-
 /* end of physfs.c ... */