X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=zone.c;h=e6a51f5be693aa7902819c1668d143a696e7c58b;hb=786b61541f4ab62cd274c5b8f53c959a6cfedc3a;hp=68958fd06371f8805926218f2b393a569333dac4;hpb=b2f3063b37549198c058412507d961916e7e70b7;p=xonotic%2Fdarkplaces.git diff --git a/zone.c b/zone.c index 68958fd0..e6a51f5b 100644 --- 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); } } @@ -460,14 +461,19 @@ void Mem_ExpandableArray_FreeRecord(memexpandablearray_t *l, void *record) size_t Mem_ExpandableArray_IndexRange(memexpandablearray_t *l) { - size_t i, j, k; - if (!l->numarrays) - return 0; - i = l->numarrays - 1; - for (j = 0, k = 0;k < l->arrays[i].numflaggedrecords;j++) - if (l->arrays[i].allocflags[j]) - k++; - return l->numrecordsperarray * i + j; + size_t i, j, k, end = 0; + for (i = 0;i < l->numarrays;i++) + { + for (j = 0, k = 0;k < l->arrays[i].numflaggedrecords;j++) + { + if (l->arrays[i].allocflags[j]) + { + end = l->numrecordsperarray * i + j + 1; + k++; + } + } + } + return end; } void *Mem_ExpandableArray_RecordAtIndex(memexpandablearray_t *l, size_t index) @@ -553,10 +559,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