allocating_and_freeing_memory_blocks
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
allocating_and_freeing_memory_blocks [2020/06/08 15:46] – created richardrussell | allocating_and_freeing_memory_blocks [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 40: | Line 40: | ||
These routines may not be as efficient or fast as the OS equivalents, | These routines may not be as efficient or fast as the OS equivalents, | ||
+ | |||
+ | //January 2021// | ||
+ | |||
+ | When this article was originally published I didn't include an equivalent of the **realloc()** functionality, | ||
+ | |||
+ | <code bb4w> | ||
+ | DEF FN_heaprealloc(p%%, | ||
+ | LOCAL a$ : N% += 23 | ||
+ | SWAP ]^a$, ](p%%-8) | ||
+ | p%% -= PTR(a$) | ||
+ | IF N% < LENa$ a$ = LEFT$(a$, | ||
+ | IF N% > LENa$ a$ += STRING$(N% - LENa$, CHR$0) | ||
+ | p%% += PTR(a$) | ||
+ | SWAP ](p%%-8), ]^a$ | ||
+ | = p%% | ||
+ | </ | ||
+ | |||
+ | Please note that whilst **FN_heapalloc()** always returns a paragraph-aligned block of memory, **FN_heaprealloc()** doesn' |
allocating_and_freeing_memory_blocks.1591631199.txt.gz · Last modified: 2024/01/05 00:18 (external edit)