Explorar o código

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.
Ryan C. Gordon %!s(int64=14) %!d(string=hai) anos
pai
achega
a7383c295f
Modificáronse 1 ficheiros con 38 adicións e 38 borrados
  1. 38 38
      src/physfs.c

+ 38 - 38
src/physfs.c

@@ -2644,6 +2644,44 @@ int PHYSFS_stat(const char *_fname, PHYSFS_Stat *stat)
 } /* 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 @@ static void setDefaultAllocator(void)
     } /* 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 ... */