Team Ai
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes847downloads
HeapCtrl.txt35 linesDownload Raw Back to Mem
1 2CHeapCtrl *HeapCtrlInit(CHeapCtrl *hc=NULL,CTask *task=NULL,CBlkPool *bp)3{//See HeapLog() for an example.4//Duplicated for Adam Task.5  if (!hc)6    hc=ACAlloc(sizeof(CHeapCtrl));7  hc->hc_signature=HEAP_CTRL_SIGNATURE_VAL;8  hc->mem_task=task;9  hc->bp=bp;10  QueInit(&hc->next_mem_blk);11  hc->last_mergable=NULL;12  hc->next_um=hc->last_um=(&hc->next_um)(U8 *)-offset(CMemUsed.next);13  return hc;14}15 16U0 HeapCtrlDel(CHeapCtrl *hc)17{//Free all blks alloced to a HeapCtrl.18  CMemBlk *m,*m1;19  if (hc) {20    PUSHFD21    CLI22    while (LBts(&hc->locked_flags,HClf_LOCKED))23      PAUSE24    m=hc->next_mem_blk;25    while (m!=&hc->next_mem_blk) {26      m1=m->next;27      MemPagTaskFree(m,hc);28      m=m1;29    }30    LBtr(&hc->locked_flags,HClf_LOCKED);31    POPFD32    Free(hc);33  }34}35