Skip to content

Add reallocarray implementation. #8871

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

Closed
wants to merge 2 commits into from

Conversation

devnexen
Copy link
Member

In a similar model as safe*alloc api but for the userland it guards
against overflow before (re)allocation, usage concealed in fpm for now.
Modern Linux and most of BSD already have it.

In a similar model as _safe_*alloc api but for the `userland` it guards
against overflow before (re)allocation, usage concealed in fpm for now.
Modern Linux and most of BSD already have it.
@iluuu1994
Copy link
Member

Might it make sense to move this to zend_alloc.h/c? Maybe it could also take the persistent flag and the call pemalloc to make to make it more generally usable? The name could also be something like safe_pemalloc_try or similar to make it more discoverable for people who know the existing functions. Let's see what others think first.

@bwoebi
Copy link
Member

bwoebi commented Jun 25, 2022

I think zend_alloc.c is not the proper place for this polyfill. However, if we were to add a ereallocarray() / pereallocarray(), these functions would belong in zend_alloc.c/h.

@devnexen
Copy link
Member Author

I think zend_alloc.c is not the proper place for this polyfill. ..

Exactly, goal is to be used just like the libc's realloc. Saying this another PR could add a similar part, feature-wise, in the zend's side.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

Ok, then let's go with no pemalloc for now, we can always add it later if there's a use-case at some point.

@devnexen devnexen force-pushed the reallocarray_intro branch from 1bdd07e to 21fc74b Compare June 26, 2022 09:50
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

LGTM

@devnexen devnexen closed this in bf29ee6 Jun 26, 2022
devnexen added a commit to devnexen/php-src that referenced this pull request Jun 27, 2022
Sort of php#8871 follow-up but on the zend part.
devnexen added a commit to devnexen/php-src that referenced this pull request Jul 2, 2022
Sort of php#8871 follow-up but on the zend part.
devnexen added a commit to devnexen/php-src that referenced this pull request Jul 2, 2022
Sort of php#8871 follow-up but on the zend part.
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.

None yet

3 participants