-
-
Notifications
You must be signed in to change notification settings - Fork 63
changed behaviour of malloc(0) and optimized calloc #631
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
base: master
Are you sure you want to change the base?
Conversation
__TICE__
only)432c6ba
to
07d546f
Compare
src/libc/calloc.src
Outdated
; inlined memset/bzero | ||
; assumes that malloc(0) returns NULL, so we can skip the check for zero size | ||
add hl, bc | ||
cpd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume it is okay for cpd
to read nonnull_ptr_from_malloc + size
07d546f
to
132611a
Compare
To reduce the complexity of this PR, I undid the
|
; test for NULL | ||
add hl, bc | ||
; or a, a ; assumes that ptr + size does not overflow on TICE | ||
sbc hl, bc | ||
pop bc ; BC = size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that this should use calc84maniac's correction to be safe. Also, I suggest removing the reference to the TI-CE, as it's not really relevant to the assumption.
; test for NULL | |
add hl, bc | |
; or a, a ; assumes that ptr + size does not overflow on TICE | |
sbc hl, bc | |
pop bc ; BC = size | |
pop bc ; BC = size | |
; test for NULL | |
add hl, bc | |
; or a, a ; assumes that ptr + size does not overflow | |
sbc hl, bc |
calloc
(when__TICE__
is defined) now uses an inlined implementation ofbzero
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.