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

malloc/realloc with a zero size may return a null pointer on success #11634

Closed
thestinger opened this issue Jan 18, 2014 · 0 comments · Fixed by #11635
Closed

malloc/realloc with a zero size may return a null pointer on success #11634

thestinger opened this issue Jan 18, 2014 · 0 comments · Fixed by #11635
Labels
I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@thestinger
Copy link
Contributor

An expression like ~() will call malloc(0) and abort if it returns a null pointer. This may also a waste of memory on implementations where it does return a non-null pointer like glibc.

thestinger added a commit that referenced this issue Jan 18, 2014
The `malloc` family of functions may return a null pointer for a
zero-size allocation, which should not be interpreted as an
out-of-memory error.

If the implementation does not return a null pointer, then handling
this will result in memory savings for zero-size types.

This also switches some code to `malloc_raw` in order to maintain a
centralized point for handling out-of-memory in `rt::global_heap`.

Closes #11634
bors added a commit that referenced this issue Jan 19, 2014
The `malloc` family of functions may return a null pointer for a
zero-size allocation, which should not be interpreted as an
out-of-memory error.

If the implementation does not return a null pointer, then handling
this will result in memory savings for zero-size types.

This also switches some code to `malloc_raw` in order to maintain a
centralized point for handling out-of-memory in `rt::global_heap`.

Closes #11634
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-slow Issue: Problems and improvements with respect to performance of generated code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant