X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_request_api.c;h=bc1fdbbdb3f3a2b52ad0ff4ef0346b86217ced62;hb=c986ec1a6abc7c4295d2fd9b666c106db17320ea;hp=42a1199bc8377537b18a74c41f2d0eea71e3d06e;hpb=cf24fb7a4a7140efa82a1ac15fac79347283d6fb;p=m6w6%2Fext-http diff --git a/http_request_api.c b/http_request_api.c index 42a1199..bc1fdbb 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -202,14 +202,14 @@ static curlioerr http_curl_ioctl_callback(CURL *, curliocmd, void *); /* }}} */ /* {{{ http_request *http_request_init(http_request *) */ -PHP_HTTP_API http_request *_http_request_init_ex(http_request *request, CURL *ch, http_request_method meth, const char *url TSRMLS_DC) +PHP_HTTP_API http_request *_http_request_init_ex(http_request *request, CURL *ch, http_request_method meth, const char *url ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC) { http_request *r; if (request) { r = request; } else { - r = emalloc(sizeof(http_request)); + r = emalloc_rel(sizeof(http_request)); } memset(r, 0, sizeof(http_request)); @@ -222,7 +222,7 @@ PHP_HTTP_API http_request *_http_request_init_ex(http_request *request, CURL *ch phpstr_init(&r->_cache.cookies); zend_hash_init(&r->_cache.options, 0, NULL, ZVAL_PTR_DTOR, 0); - TSRMLS_SET_CTX(request->tsrm_ls); + TSRMLS_SET_CTX(r->tsrm_ls); return r; } @@ -263,6 +263,7 @@ PHP_HTTP_API void _http_request_free(http_request **request) { if (*request) { TSRMLS_FETCH_FROM_CTX((*request)->tsrm_ls); + http_request_body_free(&(*request)->body); http_request_dtor(*request); efree(*request); *request = NULL; @@ -278,7 +279,7 @@ PHP_HTTP_API void _http_request_reset(http_request *request) request->conv.last_type = 0; phpstr_dtor(&request->conv.request); phpstr_dtor(&request->conv.response); - http_request_body_free(&request->body); + http_request_body_dtor(request->body); } /* }}} */ @@ -830,9 +831,17 @@ static int http_curl_raw_callback(CURL *ch, curl_infotype type, char *data, size static inline zval *_http_request_option_ex(http_request *r, HashTable *options, char *key, size_t keylen, int type TSRMLS_DC) { zval **zoption; +#ifdef ZEND_ENGINE_2 ulong h = zend_get_hash_value(key, keylen); - - if (!options || (SUCCESS != zend_hash_quick_find(options, key, keylen, h, (void **) &zoption))) { +#endif + + if (!options || +#ifdef ZEND_ENGINE_2 + (SUCCESS != zend_hash_quick_find(options, key, keylen, h, (void **) &zoption)) +#else + (SUCCESS != zend_hash_find(options, key, keylen, (void **) &zoption)) +#endif + ) { return NULL; } @@ -851,9 +860,14 @@ static inline zval *_http_request_option_ex(http_request *r, HashTable *options, } ZVAL_ADDREF(*zoption); +#ifdef ZEND_ENGINE_2 _zend_hash_quick_add_or_update(&r->_cache.options, key, keylen, h, zoption, sizeof(zval *), NULL, zend_hash_quick_exists(&r->_cache.options, key, keylen, h)?HASH_UPDATE:HASH_ADD ZEND_FILE_LINE_CC); - +#else + zend_hash_add_or_update(&r->_cache.options, key, keylen, zoption, sizeof(zval *), NULL, + zend_hash_exists(&r->_cache.options, key, keylen)?HASH_UPDATE:HASH_ADD); +#endif + return *zoption; } /* }}} */