From: Michael Wallner Date: Fri, 28 Sep 2007 07:21:28 +0000 (+0000) Subject: - take advantage of constified ZEND_API X-Git-Tag: RELEASE_1_6_0RC1~8 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=378dd0f912b3139f1a797cf19e7c4eb88d33f141;p=m6w6%2Fext-http - take advantage of constified ZEND_API --- diff --git a/http_api.c b/http_api.c index e71b087..4ab7d7e 100644 --- a/http_api.c +++ b/http_api.c @@ -192,7 +192,7 @@ STATUS _http_object_new(zend_object_value *ov, const char *cname_str, uint cname zend_class_entry *ce = parent_ce; if (cname_str && cname_len) { - if (!(ce = zend_fetch_class((char *) cname_str, cname_len, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC))) { + if (!(ce = zend_fetch_class(HTTP_ZAPI_CONST_CAST(char *) cname_str, cname_len, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC))) { return FAILURE; } if (!instanceof_function(ce, parent_ce TSRMLS_CC)) { @@ -322,7 +322,7 @@ PHP_HTTP_API zval *_http_get_server_var_ex(const char *key, size_t key_len, zend if ((SUCCESS != zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void *) &hsv)) || (Z_TYPE_PP(hsv) != IS_ARRAY)) { return NULL; } - if ((SUCCESS != zend_hash_find(Z_ARRVAL_PP(hsv), (char *) key, key_len + 1, (void *) &var))) { + if ((SUCCESS != zend_hash_find(Z_ARRVAL_PP(hsv), HTTP_ZAPI_CONST_CAST(char *) key, key_len + 1, (void *) &var))) { return NULL; } if (check && !((Z_TYPE_PP(var) == IS_STRING) && Z_STRVAL_PP(var) && Z_STRLEN_PP(var))) { diff --git a/http_cookie_api.c b/http_cookie_api.c index 9b7c9b8..f1710c3 100644 --- a/http_cookie_api.c +++ b/http_cookie_api.c @@ -77,7 +77,7 @@ PHP_HTTP_API void _http_cookie_list_free(http_cookie_list **list TSRMLS_DC) PHP_HTTP_API const char *_http_cookie_list_get_cookie(http_cookie_list *list, const char *name, size_t name_len TSRMLS_DC) { zval **cookie = NULL; - if ((SUCCESS != zend_hash_find(&list->cookies, (char *) name, name_len + 1, (void *) &cookie)) || (Z_TYPE_PP(cookie) != IS_STRING)) { + if ((SUCCESS != zend_hash_find(&list->cookies, HTTP_ZAPI_CONST_CAST(char *) name, name_len + 1, (void *) &cookie)) || (Z_TYPE_PP(cookie) != IS_STRING)) { return NULL; } return Z_STRVAL_PP(cookie); @@ -88,7 +88,7 @@ PHP_HTTP_API const char *_http_cookie_list_get_cookie(http_cookie_list *list, co PHP_HTTP_API const char *_http_cookie_list_get_extra(http_cookie_list *list, const char *name, size_t name_len TSRMLS_DC) { zval **extra = NULL; - if ((SUCCESS != zend_hash_find(&list->extras, (char *) name, name_len + 1, (void *) &extra)) || (Z_TYPE_PP(extra) != IS_STRING)) { + if ((SUCCESS != zend_hash_find(&list->extras, HTTP_ZAPI_CONST_CAST(char *) name, name_len + 1, (void *) &extra)) || (Z_TYPE_PP(extra) != IS_STRING)) { return NULL; } return Z_STRVAL_PP(extra); diff --git a/http_persistent_handle_api.c b/http_persistent_handle_api.c index 0f84ecc..47fc3b9 100644 --- a/http_persistent_handle_api.c +++ b/http_persistent_handle_api.c @@ -230,7 +230,7 @@ PHP_HTTP_API STATUS _http_persistent_handle_provide_ex(const char *name_str, siz fprintf(stderr, "PROVIDE: %s\n", name_str); #endif - if (SUCCESS == zend_hash_add(&http_persistent_handles_hash, (char *) name_str, name_len+1, (void *) &provider, sizeof(http_persistent_handle_provider), NULL)) { + if (SUCCESS == zend_hash_add(&http_persistent_handles_hash, HTTP_ZAPI_CONST_CAST(char *) name_str, name_len+1, (void *) &provider, sizeof(http_persistent_handle_provider), NULL)) { status = SUCCESS; } } @@ -246,7 +246,7 @@ PHP_HTTP_API STATUS _http_persistent_handle_acquire_ex(const char *name_str, siz *handle = NULL; LOCK(); - if (SUCCESS == zend_hash_find(&http_persistent_handles_hash, (char *) name_str, name_len+1, (void *) &provider)) { + if (SUCCESS == zend_hash_find(&http_persistent_handles_hash, HTTP_ZAPI_CONST_CAST(char *) name_str, name_len+1, (void *) &provider)) { status = http_persistent_handle_do_acquire(provider, handle TSRMLS_CC); } UNLOCK(); @@ -267,7 +267,7 @@ PHP_HTTP_API STATUS _http_persistent_handle_release_ex(const char *name_str, siz #endif LOCK(); - if (SUCCESS == zend_hash_find(&http_persistent_handles_hash, (char *) name_str, name_len+1, (void *) &provider)) { + if (SUCCESS == zend_hash_find(&http_persistent_handles_hash, HTTP_ZAPI_CONST_CAST(char *) name_str, name_len+1, (void *) &provider)) { status = http_persistent_handle_do_release(provider, handle TSRMLS_CC); } UNLOCK(); @@ -286,7 +286,7 @@ PHP_HTTP_API STATUS _http_persistent_handle_accrete_ex(const char *name_str, siz *new_handle = NULL; LOCK(); - if (SUCCESS == zend_hash_find(&http_persistent_handles_hash, (char *) name_str, name_len+1, (void *) &provider)) { + if (SUCCESS == zend_hash_find(&http_persistent_handles_hash, HTTP_ZAPI_CONST_CAST(char *) name_str, name_len+1, (void *) &provider)) { status = http_persistent_handle_do_accrete(provider, old_handle, new_handle TSRMLS_CC); } UNLOCK(); @@ -306,7 +306,7 @@ PHP_HTTP_API void _http_persistent_handle_cleanup_ex(const char *name_str, size_ LOCK(); if (name_str && name_len) { - if (SUCCESS == zend_hash_find(&http_persistent_handles_hash, (char *) name_str, name_len+1, (void *) &provider)) { + if (SUCCESS == zend_hash_find(&http_persistent_handles_hash, HTTP_ZAPI_CONST_CAST(char *) name_str, name_len+1, (void *) &provider)) { if (current_ident_only) { if ((list = http_persistent_handle_list_find(provider TSRMLS_CC))) { http_persistent_handle_list_dtor(list, provider->dtor); diff --git a/missing.h b/missing.h index 521d62a..1ad4b2a 100644 --- a/missing.h +++ b/missing.h @@ -17,6 +17,12 @@ #include "php_version.h" +#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION >= 3) +# define HTTP_ZAPI_CONST_CAST(t) (const t) +#else +# define HTTP_ZAPI_CONST_CAST(t) (t) +#endif + #if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION == 0) # define WONKY #endif