Commit c850a023 authored by Libretro-Admin's avatar Libretro-Admin
Browse files
parent 22cde637
......@@ -143,6 +143,14 @@ Z_Free(const void *ptr)
if (other == mainzone->rover)
mainzone->rover = block;
}
/*
* Always start looking from the first available free block.
* Slower, but not too bad and we don't fragment nearly as much.
*/
if (block < mainzone->rover) {
mainzone->rover = block;
}
}
......@@ -187,8 +195,13 @@ static void *Z_TagMalloc(int size, int tag)
size += 4; /* space for memory trash tester */
size = (size + 7) & ~7; /* align to 8-byte boundary */
base = rover = mainzone->rover;
start = base->prev;
/* If we ended on an allocated block, skip forward to the first free block */
start = mainzone->rover->prev;
while (mainzone->rover->tag && mainzone->rover != start) {
mainzone->rover = mainzone->rover->next;
}
base = rover = mainzone->rover;
do {
if (rover == start) /* scaned all the way around the list */
......@@ -216,7 +229,14 @@ static void *Z_TagMalloc(int size, int tag)
}
base->tag = tag; /* no longer a free block */
mainzone->rover = base->next; /* next allocation starts looking here */
/*
* If we just allocated the first available block, the next
* allocation starts looking after this one.
*/
if (base == mainzone->rover) {
mainzone->rover = base->next;
}
base->id = ZONEID;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment