Skip to content

Don't prevent passing NULL to non-Objective-C pointer parameters. #227

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

Don't prevent passing NULL to non-Objective-C pointer parameters.

The purpose for disallowing non-Objective-C pointer parameters is because there's no way to know how big a C pointer's underlying data is. But if the pointer is NULL, then there's nothing to pass, so just pass NULL and don't throw an exception. This opens up partial support for key-value observing and other APIs that take optional context pointers (so long as the caller doesn't provide one).

The purpose for disallowing non-Objective-C pointer parameters is because there's no way to know how big a C pointer's underlying data is.  But if the pointer is NULL, then there's nothing to pass, so just pass NULL and don't throw an exception.  This opens up partial support for key-value observing and other APIs that take optional context pointers (so long as the caller doesn't provide one).

PiperOrigin-RevId: 388276778
@google-cla google-cla bot added the cla: yes label Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant