void
MEMiInitHeapHead(CommonHeap *heap, HeapType type, uint32_t dataStart, uint32_t dataEnd)
{
   heap->tag = type;
   MEMInitList(&heap->list, offsetof(CommonHeap, link));
   heap->dataStart = dataStart;
   heap->dataEnd = dataEnd;
   OSInitSpinLock(&heap->lock);
   heap->flags = 0;

   if (auto list = findListContainingHeap(heap)) {
      MEMAppendListObject(list, heap);
   }
}
void
MEMInsertListObject(MemoryList *list, void *before, void *object)
{
   if (!before) {
      // Insert at end
      MEMAppendListObject(list, object);
      return;
   }

   if (list->head == before) {
      // Insert before head
      MEMPrependListObject(list, object);
      return;
   }

   // Insert to middle of list
   auto link = getLink(list, object);
   auto other = getLink(list, before);
   link->prev = other->prev;
   link->next = before;
   other->prev = object;
   list->count++;
}