]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - zone.c
don't depend on ptrdiff_t
[xonotic/darkplaces.git] / zone.c
diff --git a/zone.c b/zone.c
index 43774da6468fbaaeeec60ec8993944a245772ed7..72432d551a9ef485df3eae579130225548f657ce 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -634,7 +634,7 @@ void Mem_ExpandableArray_FreeArray(memexpandablearray_t *l)
 void *Mem_ExpandableArray_AllocRecordAtIndex(memexpandablearray_t *l, size_t index)
 {
        size_t j;
-       if (index == l->numarrays)
+       if (index >= l->numarrays)
        {
                if (l->numarrays == l->maxarrays)
                {
@@ -844,8 +844,10 @@ void MemStats_f(void)
 char* Mem_strdup (mempool_t *pool, const char* s)
 {
        char* p;
-       size_t sz = strlen (s) + 1;
-       if (s == NULL) return NULL;
+       size_t sz;
+       if (s == NULL)
+               return NULL;
+       sz = strlen (s) + 1;
        p = (char*)Mem_Alloc (pool, sz);
        strlcpy (p, s, sz);
        return p;
@@ -860,7 +862,7 @@ void Memory_Init (void)
 {
        static union {unsigned short s;unsigned char b[2];} u;
        u.s = 0x100;
-       mem_bigendian = u.b[0];
+       mem_bigendian = u.b[0] != 0;
 
        sentinel_seed = rand();
        poolchain = NULL;