-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Cleanup resource handling APIs #1042
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
Conversation
laruence
commented
Feb 2, 2015
- Drop ZEND_REGISTER/FETCH_RESOURCE
- Avoiding double checking of passed_id's type
- Resource types are passed by registers now.
} | ||
|
||
ZEND_API void *zend_fetch_resource(zval *passed_id, int default_id, const char *resource_type_name, int *found_resource_type, int num_resource_types, ...) | ||
ZEND_API void *zend_fetch_resource2(zend_resource *res, const char *resource_type_name, int *found_type, int resource_type1, int resource_type2) |
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.
We may remove "found_type" argument and use res->type in caller context instead.
We also may use res->ptr instead of returned value.
In this case we may change this function into zend_verify_resource().
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.
- make sense....
- we need to return a flag to tell if it is expected type
@@ -2765,7 +2765,9 @@ PHP_FUNCTION(curl_setopt) | |||
return; | |||
} | |||
|
|||
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl); | |||
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) { |
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 don't see how three lines of code instead of one is an improvement.
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.
the improvement is that we use zend_resource directly as parameters.