Made __PHYSFS_ui64FitsAddressSpace's behaviour match its name.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 24 Aug 2010 10:03:25 -0400
changeset 1112 12e187aa051c
parent 1111 20d7c2d95a98
child 1113 2136d64bd1ad
Made __PHYSFS_ui64FitsAddressSpace's behaviour match its name.
src/physfs.c
src/physfs_internal.h
src/platform_macosx.c
--- a/src/physfs.c	Sun Aug 22 20:20:04 2010 -0400
+++ b/src/physfs.c	Tue Aug 24 10:03:25 2010 -0400
@@ -2246,7 +2246,7 @@
 
 static void *mallocAllocatorMalloc(PHYSFS_uint64 s)
 {
-    BAIL_IF_MACRO(__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
+    BAIL_IF_MACRO(!__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
     #undef malloc
     return malloc((size_t) s);
 } /* mallocAllocatorMalloc */
@@ -2254,7 +2254,7 @@
 
 static void *mallocAllocatorRealloc(void *ptr, PHYSFS_uint64 s)
 {
-    BAIL_IF_MACRO(__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
+    BAIL_IF_MACRO(!__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
     #undef realloc
     return realloc(ptr, (size_t) s);
 } /* mallocAllocatorRealloc */
--- a/src/physfs_internal.h	Sun Aug 22 20:20:04 2010 -0400
+++ b/src/physfs_internal.h	Tue Aug 24 10:03:25 2010 -0400
@@ -1046,8 +1046,8 @@
  *  size_t, suitable to pass to malloc. This is kinda messy, but effective.
  */
 #define __PHYSFS_ui64FitsAddressSpace(s) ( \
-    (sizeof (PHYSFS_uint64) > sizeof (size_t)) && \
-    ((s) > (__PHYSFS_UI64(0xFFFFFFFFFFFFFFFF) >> (64-(sizeof(size_t)*8)))) \
+    (sizeof (PHYSFS_uint64) <= sizeof (size_t)) || \
+    ((s) < (__PHYSFS_UI64(0xFFFFFFFFFFFFFFFF) >> (64-(sizeof(size_t)*8)))) \
 )
 
 
--- a/src/platform_macosx.c	Sun Aug 22 20:20:04 2010 -0400
+++ b/src/platform_macosx.c	Tue Aug 24 10:03:25 2010 -0400
@@ -324,14 +324,14 @@
 
 static void *macosxAllocatorMalloc(PHYSFS_uint64 s)
 {
-    BAIL_IF_MACRO(__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
+    BAIL_IF_MACRO(!__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
     return CFAllocatorAllocate(cfallocdef, (CFIndex) s, 0);
 } /* macosxAllocatorMalloc */
 
 
 static void *macosxAllocatorRealloc(void *ptr, PHYSFS_uint64 s)
 {
-    BAIL_IF_MACRO(__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
+    BAIL_IF_MACRO(!__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
     return CFAllocatorReallocate(cfallocdef, ptr, (CFIndex) s, 0);
 } /* macosxAllocatorRealloc */