]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - zone.c
simplifying Warsow-style physics code even more, as it now can use a common code...
[xonotic/darkplaces.git] / zone.c
diff --git a/zone.c b/zone.c
index e6a51f5be693aa7902819c1668d143a696e7c58b..0274e0665573ac6a65f378932db59f69c83a5cc7 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -204,7 +204,10 @@ static void _Mem_FreeBlock(memheader_t *mem, const char *filename, int fileline)
 void _Mem_Free(void *data, const char *filename, int fileline)
 {
        if (data == NULL)
-               Sys_Error("Mem_Free: data == NULL (called at %s:%i)", filename, fileline);
+       {
+               Con_DPrintf("Mem_Free: data == NULL (called at %s:%i)", filename, fileline);
+               return;
+       }
 
        if (developer.integer && developer_memorydebug.integer)
        {
@@ -411,7 +414,7 @@ void *Mem_ExpandableArray_AllocRecord(memexpandablearray_t *l)
                        {
                                memexpandablearray_array_t *oldarrays = l->arrays;
                                l->maxarrays = max(l->maxarrays * 2, 128);
-                               l->arrays = Mem_Alloc(l->mempool, l->maxarrays * sizeof(*l->arrays));
+                               l->arrays = (memexpandablearray_array_t*) Mem_Alloc(l->mempool, l->maxarrays * sizeof(*l->arrays));
                                if (oldarrays)
                                {
                                        memcpy(l->arrays, oldarrays, l->numarrays * sizeof(*l->arrays));
@@ -419,7 +422,7 @@ void *Mem_ExpandableArray_AllocRecord(memexpandablearray_t *l)
                                }
                        }
                        l->arrays[i].numflaggedrecords = 0;
-                       l->arrays[i].data = Mem_Alloc(l->mempool, (l->recordsize + 1) * l->numrecordsperarray);
+                       l->arrays[i].data = (unsigned char *) Mem_Alloc(l->mempool, (l->recordsize + 1) * l->numrecordsperarray);
                        l->arrays[i].allocflags = l->arrays[i].data + l->recordsize * l->numrecordsperarray;
                        l->numarrays++;
                }
@@ -439,7 +442,16 @@ void *Mem_ExpandableArray_AllocRecord(memexpandablearray_t *l)
        }
 }
 
-void Mem_ExpandableArray_FreeRecord(memexpandablearray_t *l, void *record)
+/*****************************************************************************
+ * IF YOU EDIT THIS:
+ * If this function was to change the size of the "expandable" array, you have
+ * to update r_shadow.c
+ * Just do a search for "range =", R_ShadowClearWorldLights would be the first
+ * function to look at. (And also seems like the only one?) You  might have to
+ * move the  call to Mem_ExpandableArray_IndexRange  back into for(...) loop's
+ * condition
+ */
+void Mem_ExpandableArray_FreeRecord(memexpandablearray_t *l, void *record) // const!
 {
        size_t i, j;
        unsigned char *p = (unsigned char *)record;
@@ -459,7 +471,7 @@ void Mem_ExpandableArray_FreeRecord(memexpandablearray_t *l, void *record)
        }
 }
 
-size_t Mem_ExpandableArray_IndexRange(memexpandablearray_t *l)
+size_t Mem_ExpandableArray_IndexRange(const memexpandablearray_t *l)
 {
        size_t i, j, k, end = 0;
        for (i = 0;i < l->numarrays;i++)
@@ -476,7 +488,7 @@ size_t Mem_ExpandableArray_IndexRange(memexpandablearray_t *l)
        return end;
 }
 
-void *Mem_ExpandableArray_RecordAtIndex(memexpandablearray_t *l, size_t index)
+void *Mem_ExpandableArray_RecordAtIndex(const memexpandablearray_t *l, size_t index)
 {
        size_t i, j;
        i = index / l->numrecordsperarray;