Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] Properly handle max malloc (=32764 bytes) in v7malloc #2110

Merged
merged 3 commits into from
Nov 20, 2024
Merged

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Nov 20, 2024

More v7malloc fixes paying proper attention to signed vs unsigned compares, 16-bit multiply overflow and address wrapping, all used within the allocation routine. This version properly handles the maximum allocation possible given it'ssbrk implementation and 16-bit int, which is malloc(32764).

Compiling with -Wextra also produced more warnings which are now fixed.

V7malloc is currently not used within any applications except fm, where it was required due to our current malloc fragmenting the heap. I am considering replacing the libc malloc with v7malloc. There is considerable difference in heap usage and fragmentation between malloc and realloc between the two implementations. Actual allocation speed performance is considered as less important than better heap management for our smaller address space.

@ghaerr
Copy link
Owner Author

ghaerr commented Nov 20, 2024

Also corrected max allocation and errno handling in the standard ELKS libc malloc. This allows @ccoffing's malloc libc test to (finally) succeed.

@ghaerr ghaerr merged commit 6ac0fcb into master Nov 20, 2024
2 checks passed
@ghaerr ghaerr deleted the v7malloc2 branch November 20, 2024 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant