cf_malloc(FALSE) uses TOS Malloc / Mxalloc for no good reason
mikrosk opened this issue · 4 comments
I thought that cf_malloc
is used in rare cases where TOS M(x)alloc is explicitly needed, like malloc_global
. However it seems that e.g. USERBLKs are using it for no particular reason creating havoc for simpler memory allocators as described by @czietz here and here.
Perhaps in the earlier times dependency on mintlib (or libc in general) wasn't desired but nowadays it doesn't matter.
Another good point would be why the hell 8 bytes need separate dynamic allocation.
I did a grep through the sources, and added a fix. cf_malloc is only defined in intern.h so should be local to cflib and not be exported, so i hope the fix can be done in cflib (unless some brain-damaged app imports that function illegaly).
I also changed fix_dial to allocate all needed USERBLKs in one go instead of allocating each structure separately. This could maybe further improved to provide an additional function that fixes all objects of a resource in one go, instead of doing it per tree, but this would require also changes to applications that use the function currently (found only QED and toswin2 so far, are there any others?)
Tested only with QED so far, and found no issues.
Oh nice, many thanks for that. I've rerun all the jobs (qed, toswin2, bootable freemint packages), @czietz as you have a working setup with the bug present, can you verify that downloading the latest qed fixes the problem in EmuTOS?
found only QED and toswin2 so far, are there any others?
If you ask generally, then I know of HD Driver and ... my mxPlay. :)
Awesome, thanks to both of you.