]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - zone.c
Expandable arrays: memset to zero newly returned records (to be consistent with Mem_A...
[xonotic/darkplaces.git] / zone.c
diff --git a/zone.c b/zone.c
index 3cbde6c9f64e7d68d738c1aa2eabd56e45473307..175b25a677ddf1cfbbb765da831194de7561d591 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -393,7 +393,7 @@ void Mem_ExpandableArray_FreeArray(memexpandablearray_t *l)
        size_t i;
        if (l->maxarrays)
        {
-               for (i = 0;i != l->numarrays;l++)
+               for (i = 0;i != l->numarrays;i++)
                        Mem_Free(l->arrays[i].data);
                Mem_Free(l->arrays);
        }
@@ -431,6 +431,7 @@ void *Mem_ExpandableArray_AllocRecord(memexpandablearray_t *l)
                                {
                                        l->arrays[i].allocflags[j] = true;
                                        l->arrays[i].numflaggedrecords++;
+                                       memset(l->arrays[i].data + l->recordsize * j, 0, l->recordsize);
                                        return (void *)(l->arrays[i].data + l->recordsize * j);
                                }
                        }
@@ -477,7 +478,7 @@ void *Mem_ExpandableArray_RecordAtIndex(memexpandablearray_t *l, size_t index)
        j = index % l->numrecordsperarray;
        if (i >= l->numarrays || !l->arrays[i].allocflags[j])
                return NULL;
-       return (void *)l->arrays[i].data + j * l->recordsize;
+       return (void *)(l->arrays[i].data + j * l->recordsize);
 }
 
 
@@ -553,10 +554,21 @@ void MemStats_f(void)
 {
        Mem_CheckSentinelsGlobal();
        R_TextureStats_Print(false, false, true);
+       GL_Mesh_ListVBOs(false);
        Mem_PrintStats();
 }
 
 
+char* Mem_strdup (mempool_t *pool, const char* s)
+{
+       char* p;
+       size_t sz = strlen (s) + 1;
+       if (s == NULL) return NULL;
+       p = (char*)Mem_Alloc (pool, sz);
+       strlcpy (p, s, sz);
+       return p;
+}
+
 /*
 ========================
 Memory_Init