Platform deinit should happen last, since other deinit bits might depend on it.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 07 Sep 2016 21:21:59 -0400
changeset 1382 65c84cb21698
parent 1381 e1660c553b8e
child 1383 1b6b14b5eebe
Platform deinit should happen last, since other deinit bits might depend on it.
src/physfs.c
--- a/src/physfs.c	Fri Aug 26 18:46:11 2016 -0400
+++ b/src/physfs.c	Wed Sep 07 21:21:59 2016 -0400
@@ -1286,8 +1286,6 @@
 
 static int doDeinit(void)
 {
-    BAIL_IF_MACRO(!__PHYSFS_platformDeinit(), ERRPASS, 0);
-
     closeFileHandleList(&openWriteList);
     BAIL_IF_MACRO(!PHYSFS_setWriteDir(NULL), PHYSFS_ERR_FILES_STILL_OPEN, 0);
 
@@ -1335,6 +1333,10 @@
         allocator.Deinit();
 
     errorLock = stateLock = NULL;
+
+    /* !!! FIXME: what on earth are you supposed to do if this fails? */
+    BAIL_IF_MACRO(!__PHYSFS_platformDeinit(), ERRPASS, 0);
+
     return 1;
 } /* doDeinit */