It's verification time!!!
#2
Up next is the static memory manager:
Code: (Select All)
' MEM_STATIC memory manager
/'
    mem_static uses a pointer called mem_static_pointer to allocate linear memory.
    It can also change mem_static_pointer back to a previous location, effectively erasing
    any memory after that point.
    Because memory cannot be guaranteed to be allocated in exactly the same location
    after realloc which QB64 requires to keep functionality of previous pointers when
    the current block of memory is full QB64 creates an entirely new block, much larger
    than the previous block (at least 2x), and "writes-off" the previous block as un-
    reclaimable memory. This tradeoff is worth the speed it recovers.
    This allocation strategy can be shown as follows: (X=1MB)
    X
    XX
    XXXX
    XXXXXXXX
    XXXXXXXXXXXXXXXX
    etc.
'/

proc SYSTEM_BUS_T.mem64_static_malloc(size as uinteger) as SYSTEM_TYPE ptr
    size += 7
    size -= (size and 7) ' align to 8 byte boundry
    if ((mov(mem_static_pointer,mem_static_pointer add size)) < mem_static_limit) then
        return mem_static_pointer - size
    end if   
    mem_static_size = (mem_static_size shl 1) + size
    mem_static = malloc(mem_static_size)
    if (mem_static) then
        mem_static_pointer = mem_static + size
        mem_static_limit = mem_static + mem_static_size
        return mem_static_pointer - size
    else
        error(504)
    end if
end proc

def SYSTEM_BUS_T.mem64_static_restore(restore_point as SYSTEM_TYPE ptr)
    if ((restore_point >= mem_static) and (restore_point <= mem_static_limit)) then
        mem_static_pointer = restore_point
    else
        ' if restore_point is not in the current block, use t=start of current block as a new base
        mem_static_pointer = mem_static
    end if
end def
Reply


Messages In This Thread
It's verification time!!! - by fatman2021 - 07-08-2022, 12:16 AM
RE: It's verification time!!! - by fatman2021 - 07-08-2022, 12:07 PM
RE: It's verification time!!! - by bplus - 07-08-2022, 01:00 PM
RE: It's verification time!!! - by dcromley - 07-08-2022, 03:18 PM
RE: It's verification time!!! - by bplus - 07-08-2022, 04:17 PM
RE: It's verification time!!! - by dcromley - 07-08-2022, 05:41 PM
RE: It's verification time!!! - by bplus - 07-08-2022, 05:47 PM
RE: It's verification time!!! - by Kernelpanic - 07-08-2022, 09:50 PM
RE: It's verification time!!! - by fatman2021 - 07-09-2022, 12:20 AM
RE: It's verification time!!! - by fatman2021 - 07-09-2022, 01:30 AM
RE: It's verification time!!! - by fatman2021 - 07-09-2022, 06:01 PM
RE: It's verification time!!! - by fatman2021 - 07-10-2022, 10:13 PM
RE: It's verification time!!! - by fatman2021 - 07-11-2022, 06:26 PM
RE: It's verification time!!! - by fatman2021 - 07-13-2022, 04:50 PM
RE: It's verification time!!! - by fatman2021 - 07-15-2022, 01:43 AM
RE: It's verification time!!! - by fatman2021 - 07-15-2022, 11:30 PM
RE: It's verification time!!! - by fatman2021 - 07-17-2022, 12:56 AM
RE: It's verification time!!! - by fatman2021 - 07-19-2022, 01:14 AM
RE: It's verification time!!! - by fatman2021 - 07-20-2022, 09:52 PM
RE: It's verification time!!! - by dbox - 07-20-2022, 10:07 PM
RE: It's verification time!!! - by fatman2021 - 07-20-2022, 11:24 PM
RE: It's verification time!!! - by vince - 07-21-2022, 01:36 AM
RE: It's verification time!!! - by fatman2021 - 07-21-2022, 06:46 PM
RE: It's verification time!!! - by vince - 07-28-2022, 07:37 AM
RE: It's verification time!!! - by fatman2021 - 07-28-2022, 03:19 PM
RE: It's verification time!!! - by fatman2021 - 07-25-2022, 02:47 AM
RE: It's verification time!!! - by fatman2021 - 07-27-2022, 09:03 PM
RE: It's verification time!!! - by mnrvovrfc - 07-27-2022, 10:08 PM
RE: It's verification time!!! - by fatman2021 - 07-27-2022, 10:50 PM
RE: It's verification time!!! - by fatman2021 - 07-28-2022, 04:04 PM
RE: It's verification time!!! - by fatman2021 - 08-10-2022, 01:13 PM
RE: It's verification time!!! - by fatman2021 - 08-15-2022, 04:50 PM



Users browsing this thread: 12 Guest(s)