TempleOSCDV4.01.ISO
This commit is contained in:
1 parent
0e0592d9a6
commit
fedf66361e
85 files changed
+2463
-2376
No files matched your search
+16
-16
@@ -23,21 +23,21 @@ Return: NULL if out of memory.
|
||||
CLI
|
||||
while (LBts(&bp->locked_flags,BPlf_LOCKED))
|
||||
PAUSE
|
||||
if (num<FREE_PAGE_HASH_SIZE) {
|
||||
if (num<MEM_FREE_PAGE_HASH_SIZE) {
|
||||
if (result=bp->free_page_hash[num]) {
|
||||
bp->free_page_hash[num]=result->next;
|
||||
goto at_done;
|
||||
}
|
||||
i=Bsr(FREE_PAGE_HASH_SIZE)+1;
|
||||
i=Bsr(MEM_FREE_PAGE_HASH_SIZE)+1;
|
||||
} else {
|
||||
//We'll now round-up to a power of two.
|
||||
//There is some overhead on allocations and
|
||||
//we wouldn't want to round to the next
|
||||
//power of two if a power of two was requested.
|
||||
//So we use a little more than a power of two.
|
||||
num-=2;
|
||||
num-=MEM_EXTRA_HASH2_PAGES;
|
||||
i=Bsr(num)+1;
|
||||
num=1<<i+2;
|
||||
num=1<<i+MEM_EXTRA_HASH2_PAGES;
|
||||
if (result=bp->free_page_hash2[i]) {
|
||||
bp->free_page_hash2[i]=result->next;
|
||||
goto at_done;
|
||||
@@ -50,11 +50,11 @@ Return: NULL if out of memory.
|
||||
//freed larger size block... and, screw-it, return the whole thing.
|
||||
do {
|
||||
if (result=bp->free_page_hash2[++i]) {
|
||||
num=1<<i+2;
|
||||
num=1<<i+MEM_EXTRA_HASH2_PAGES;
|
||||
bp->free_page_hash2[i]=result->next;
|
||||
goto at_done;
|
||||
}
|
||||
} while (i<64-PAGE_BITS-1);
|
||||
} while (i<64-MEM_PAGE_BITS-1);
|
||||
num=0;
|
||||
result=NULL; //Out of memory
|
||||
goto at_done;
|
||||
@@ -67,7 +67,7 @@ Return: NULL if out of memory.
|
||||
goto at_done;
|
||||
} else {
|
||||
result->pages-=num;
|
||||
result(U8 *)+=result->pages<<PAGE_BITS;
|
||||
result(U8 *)+=result->pages<<MEM_PAGE_BITS;
|
||||
result->pages=num;
|
||||
goto at_done;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ Return: NULL if out of memory.
|
||||
}
|
||||
at_done:
|
||||
*_pages512=num;
|
||||
bp->used_u8s+=num<<PAGE_BITS;
|
||||
bp->used_u8s+=num<<MEM_PAGE_BITS;
|
||||
LBtr(&bp->locked_flags,BPlf_LOCKED);
|
||||
POPFD
|
||||
return result;
|
||||
@@ -92,8 +92,8 @@ U0 Mem512Free(CMemBlk *m,I64 pages512,CBlkPool *bp=NULL)
|
||||
PAUSE
|
||||
m->mb_signature=MBS_UNUSED_SIGNATURE_VAL;
|
||||
m->pages=pages512;
|
||||
bp->used_u8s-=pages512<<PAGE_BITS;
|
||||
if (pages512<FREE_PAGE_HASH_SIZE) {
|
||||
bp->used_u8s-=pages512<<MEM_PAGE_BITS;
|
||||
if (pages512<MEM_FREE_PAGE_HASH_SIZE) {
|
||||
m->next=bp->free_page_hash[pages512];
|
||||
bp->free_page_hash[pages512]=m;
|
||||
} else {
|
||||
@@ -102,7 +102,7 @@ U0 Mem512Free(CMemBlk *m,I64 pages512,CBlkPool *bp=NULL)
|
||||
//we wouldn't want to round to the next
|
||||
//power of two if a power of two was requested.
|
||||
//So we use a little more than a power of two.
|
||||
pages512-=2;
|
||||
pages512-=MEM_EXTRA_HASH2_PAGES;
|
||||
i=Bsr(pages512);
|
||||
m->next=bp->free_page_hash2[i];
|
||||
bp->free_page_hash2[i]=m;
|
||||
@@ -124,12 +124,12 @@ Return: NULL if out of memory.
|
||||
if (result=Mem512Alloc(_pages512,hc->bp)) {
|
||||
QueIns(result,hc->last_mem_blk);
|
||||
result->mb_signature=MBS_USED_SIGNATURE_VAL;
|
||||
hc->alloced_u8s+=*_pages512<<PAGE_BITS;
|
||||
hc->alloced_u8s+=*_pages512<<MEM_PAGE_BITS;
|
||||
|
||||
//Tidy-up free lst (Move into heap hash)
|
||||
//because if free lst gets long, delay causes crash
|
||||
threshold=HEAP_HASH_SIZE>>4;
|
||||
#assert HEAP_HASH_SIZE>>4>=sizeof(U8 *)
|
||||
threshold=MEM_HEAP_HASH_SIZE>>4;
|
||||
#assert MEM_HEAP_HASH_SIZE>>4>=sizeof(U8 *)
|
||||
do {
|
||||
cnt=0;
|
||||
_uum=&hc->malloc_free_lst;
|
||||
@@ -147,7 +147,7 @@ Return: NULL if out of memory.
|
||||
}
|
||||
}
|
||||
threshold<<=1;
|
||||
} while (cnt>8 && threshold<=HEAP_HASH_SIZE);
|
||||
} while (cnt>8 && threshold<=MEM_HEAP_HASH_SIZE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ U0 Mem512TaskFree(CMemBlk *m,CHeapCtrl *hc)
|
||||
SysBadFree(m);
|
||||
else {
|
||||
QueRem(m);
|
||||
hc->alloced_u8s-=m->pages<<PAGE_BITS;
|
||||
hc->alloced_u8s-=m->pages<<MEM_PAGE_BITS;
|
||||
Mem512Free(m,m->pages,hc->bp);
|
||||
}
|
||||
POPFD
|
||||
|
||||
Reference in new issue
Block a user