Experimental ReAlloc implementation

Stopped scrolling editor title, and blinking MENU
This commit is contained in:
xmm15 2020-02-17 19:30:10 -06:00
parent 8e6f2a4cec
commit f03359889c
8 changed files with 651 additions and 627 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -558,6 +558,7 @@ public extern I64 Seed(I64 seed=0,CTask *task=NULL);
public extern U8 *ZCAlloc(I64 size);
public extern U8 *ZMAlloc(I64 size);
public extern U8 *ZMAllocIdent(U8 *src);
public extern U8 *ZReAlloc(U8 *src, U64 size);
#help_index "Memory/BlkPool"
public extern U0 BlkPoolAdd(CBlkPool *bp,CMemBlk *m,I64 pags);
@ -567,13 +568,12 @@ public extern U0 MemPagFree(CMemBlk *m,CBlkPool *bp=NULL);
#help_index "Memory/Heap"
public extern U8 *CAlloc(I64 size,CTask *mem_task=NULL);
public extern U8 *CAllocAligned(I64 size,I64 alignment,
CTask *mem_task=NULL,I64 misalignment=0);
public extern U8 *CAllocAligned(I64 size,I64 alignment,CTask *mem_task=NULL,I64 misalignment=0);
public _extern _FREE U0 Free(U8 *addr);
public _extern _MALLOC U8 *MAlloc(I64 size,CTask *mem_task=NULL);
public extern U8 *MAllocAligned(I64 size,I64 alignment,
CTask *mem_task=NULL,I64 misalignment=0);
public extern U8 *MAllocAligned(I64 size,I64 alignment,CTask *mem_task=NULL,I64 misalignment=0);
public extern U8 *MAllocIdent(U8 *src,CTask *mem_task=NULL);
public extern U8 *ReAlloc(U8 *src, U64 size, CTask *mem_task=NULL);
public _extern _MHEAP_CTRL CHeapCtrl *MHeapCtrl(U8 *src);
public _extern _MSIZE I64 MSize(U8 *src); //size of heap object
public _extern _MSIZE2 I64 MSize2(U8 *src); //Internal size
@ -740,7 +740,7 @@ public extern CDate local_time_offset;
public extern U8 CMOSRegRead(I64 register);
public extern U0 CMOSRegWrite(I64 register, I64 val);
public extern Bool CMOSIsBcd();
public extern U0 TimeSet(CDateStruct *ds);
public extern U0 TimeSet(CDateStruct *ds);
#help_index "Time/Date;Date"
#help_file "::/Doc/Date"

View file

@ -443,6 +443,32 @@ U8 *CAllocAligned(I64 size,I64 alignment,
return res;
}
U8 *ReAlloc(U8 *ptr, U64 new_size, CTask *mem_task=NULL)
{//Resize chunk previously MAlloc'ed. if new_size is zero then act as Free.
//If ptr is NULL then act as MAlloc. if both are NULL/0 does nothing (Free(NULL))
//Useless for changing chunk sizes smaller than 8 bytes because MAlloc allocs 8 bytes at a time.
U8 *res;
if(!new_size)
{
Free(ptr); //we can free NULL
return NULL;
}
res = MAlloc(new_size, mem_task);
if(!ptr)
return res;
MemCopy(res, ptr, MinI64(MSize(ptr), new_size));
Free(ptr);
return res;
}
U8 *ZReAlloc(U8 *ptr, I64 new_size)
{//Realloc in Zenith's heap.
return ReAlloc(ptr, new_size, zenith_task);
}
U8 *StrNew(U8 *buf,CTask *mem_task=NULL)
{//Accepts a $LK,"CTask",A="MN:CTask"$ or $LK,"CHeapCtrl",A="MN:CHeapCtrl"$.NULL allocs off current task's heap.
U8 *res;

Binary file not shown.

View file

@ -102,7 +102,7 @@ public Bool DocEd(CDoc *doc,I64 dof_flags=0)
bdoc->flags|=DOCF_BORDER_DOC;
DocPrint(bdoc,"$$CM+TY+LX+NC,0,-1$$");
DocPrint(bdoc,"$$TX+RX+BD,\"[X]\"$$");
DocPrint(bdoc,"$$BK,1$$$$TX+LX+BD,\"MENU\"$$$$BK,0$$");
DocPrint(bdoc,"$$TX+LX+BD,\"MENU\"$$");
old_task_title=StrNew(Fs->task_title);
if (Fs->title_src!=TTS_LOCKED_CONST) {
@ -110,7 +110,7 @@ public Bool DocEd(CDoc *doc,I64 dof_flags=0)
MemCopy(Fs->task_title,doc->filename.name,STR_LEN-1);
}
doc_e=DocPrint(bdoc,"$$DA-TRM-P+BD+RD+CX+IV,LEN=STR_LEN-1,"
"A=\"%%s...\",SCX=16$$");
"A=\"%%s\"$$");
doc_e->data=&Fs->task_title;
DocDataFormat(bdoc,doc_e);