}
}
-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;
}
}
-size_t Mem_ExpandableArray_IndexRange(memexpandablearray_t *l)
+size_t Mem_ExpandableArray_IndexRange(const 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)
+void *Mem_ExpandableArray_RecordAtIndex(const memexpandablearray_t *l, size_t index)
{
size_t i, j;
i = index / l->numrecordsperarray;