-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Convert resources to objects in ext/zlib #5680
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
@@ -47,6 +47,7 @@ typedef struct _php_zlib_context { | |||
int status; | |||
size_t inflateDictlen; | |||
php_zlib_buffer buffer; | |||
zend_object std; | |||
} php_zlib_context; |
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.
Apparently, the same data structure is used during inflation and deflation... Which leads to the question if we should separate it to a zlib_inflate_context
and a zlib_deflate_context
?
le_deflate = zend_register_list_destructors_ex(deflate_rsrc_dtor, NULL, "zlib.deflate", module_number); | ||
le_inflate = zend_register_list_destructors_ex(inflate_rsrc_dtor, NULL, "zlib.inflate", module_number); | ||
zend_class_entry inflate_ce; | ||
INIT_CLASS_ENTRY(inflate_ce, "InflateContext", class_InflateContext_methods); |
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'm wondering if InflateContext
is really a good naming choice: if we later want to add an OO API, then InflateContext::add
seems a bit weird for me. Maybe we should prefer Inflator
/Deflator
?
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 current name sound ok to me.
deflate_add(): supplied resource is not a valid zlib deflate resource | ||
Flush mode must be ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK or ZLIB_FINISH | ||
deflate_add(): Argument #1 ($context) must be of type DeflateContext, resource given | ||
deflate_add(): Argument #3 ($flush_behavior) must be one of ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK, or ZLIB_FINISH |
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'll commit these error message changes separately
364352f
to
a75e120
Compare
@@ -930,71 +978,69 @@ PHP_FUNCTION(inflate_add) | |||
break; | |||
|
|||
default: | |||
zend_value_error( | |||
"Flush mode must be ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK or ZLIB_FINISH"); | |||
zend_argument_value_error(3, "must be one of ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK, ZLIB_FINISH"); |
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 think the or
should be retained here.
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.
Fixed these in the commit to master
out = zend_string_realloc(out, buffer_used, 0); | ||
ZSTR_VAL(out)[buffer_used] = 0; | ||
RETURN_STR(out); | ||
complete: { |
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.
You can drop the awkward code block here.
le_deflate = zend_register_list_destructors_ex(deflate_rsrc_dtor, NULL, "zlib.deflate", module_number); | ||
le_inflate = zend_register_list_destructors_ex(inflate_rsrc_dtor, NULL, "zlib.inflate", module_number); | ||
zend_class_entry inflate_ce; | ||
INIT_CLASS_ENTRY(inflate_ce, "InflateContext", class_InflateContext_methods); |
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 current name sound ok to me.
No description provided.