Skip to content

Conversation

@ZERICO2005
Copy link
Contributor

@ZERICO2005 ZERICO2005 commented Sep 6, 2025

__simple_malloc and __standard_malloc now return NULL when malloc(0) is called.

calloc (when __TICE__ is defined) now uses an inlined implementation of bzero which uses the $E40000 address to speed up the zero filling of memory.

Otherwise, it will use the previous memset implementation when __TICE__ is undefined.

@ZERICO2005 ZERICO2005 changed the title optimized the zero filling in calloc (__TICE__ only) changed behaviour of malloc(0) and optimized zero filling in calloc Sep 6, 2025
@ZERICO2005 ZERICO2005 changed the title changed behaviour of malloc(0) and optimized zero filling in calloc changed behaviour of malloc(0) and optimized calloc Sep 6, 2025
@runer112 runer112 self-requested a review September 6, 2025 22:31
@ZERICO2005
Copy link
Contributor Author

ZERICO2005 commented Sep 16, 2025

To reduce the complexity of this PR, I undid the allocator switches to nonzero_fill_calloc when malloc(0) is known to return NULL commits for now (which essentially added 4 different calloc variants). That way we can focus on the two important changes that will be made in this PR:

  • Changing the behavior of __simple_malloc(0) and __standard_malloc(0) to return NULL.
  • Optimizing calloc zero filling by using the $E40000 all zeros address

@ZERICO2005 ZERICO2005 marked this pull request as ready for review September 21, 2025 00:56
@runer112 runer112 self-assigned this Oct 16, 2025
@runer112 runer112 removed their assignment Oct 19, 2025
Copy link
Member

@runer112 runer112 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all checks pass, seems good.

@adriweb adriweb merged commit a494909 into master Nov 1, 2025
7 of 9 checks passed
@adriweb adriweb deleted the opt_calloc branch November 1, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants