- fix PHP4 build
authorMichael Wallner <mike@php.net>
Wed, 7 Feb 2007 15:31:50 +0000 (15:31 +0000)
committerMichael Wallner <mike@php.net>
Wed, 7 Feb 2007 15:31:50 +0000 (15:31 +0000)
- use zend_hash_func instead of zend_get_hash_value

http.c
http_message_object.c
http_request_api.c
http_request_object.c
phpstr/phpstr.h

diff --git a/http.c b/http.c
index 364710d..0118e6d 100644 (file)
--- a/http.c
+++ b/http.c
@@ -243,7 +243,7 @@ PHP_INI_MH(http_update_allowed_methods)
 #ifdef HTTP_HAVE_PERSISTENT_HANDLES
 PHP_INI_MH(http_update_persistent_handle_ident)
 {
-       HTTP_G->persistent.handles.ident.h = zend_get_hash_value(new_value, HTTP_G->persistent.handles.ident.l = new_value_length+1);
+       HTTP_G->persistent.handles.ident.h = zend_hash_func(new_value, HTTP_G->persistent.handles.ident.l = new_value_length+1);
        return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
 }
 #endif
@@ -300,7 +300,9 @@ PHP_MINIT_FUNCTION(http)
 #ifdef HTTP_HAVE_CURL
 #      ifdef HTTP_HAVE_PERSISTENT_HANDLES
                        (SUCCESS != PHP_MINIT_CALL(http_persistent_handle)) ||
+#              ifdef ZEND_ENGINE_2
                        (SUCCESS != PHP_MINIT_CALL(http_request_pool)) ||
+#              endif
 #      endif
                        (SUCCESS != PHP_MINIT_CALL(http_request))       ||
 #      ifdef ZEND_ENGINE_2
index fd33e32..4ad0916 100644 (file)
@@ -412,7 +412,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type
        http_message *msg = obj->message;
        zval *return_value;
 #ifdef WONKY
-       ulong h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member)+1);
+       ulong h = zend_hash_func(Z_STRVAL_P(member), Z_STRLEN_P(member)+1);
 #else
        zend_property_info *pinfo = zend_get_property_info(obj->zo.ce, member, 1 TSRMLS_CC);
        
@@ -520,7 +520,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va
        http_message *msg = obj->message;
        zval *cpy = NULL;
 #ifdef WONKY
-       ulong h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1);
+       ulong h = zend_hash_func(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1);
 #else
        zend_property_info *pinfo = zend_get_property_info(obj->zo.ce, member, 1 TSRMLS_CC);
        
index 92fe1ec..3396dba 100644 (file)
@@ -1023,24 +1023,16 @@ static int http_curl_raw_callback(CURL *ch, curl_infotype type, char *data, size
 /* {{{ static inline zval *http_request_option(http_request *, HashTable *, char *, size_t, int) */
 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);
-#else
-       ulong h = 0;
-#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;
+       if (options) {
+               zval **zoption;
+               ulong h = zend_hash_func(key, keylen);
+               
+               if (SUCCESS == zend_hash_quick_find(options, key, keylen, h, (void *) &zoption)) {
+                       return http_request_option_cache_ex(r, key, keylen, h, zval_copy(type, *zoption));
+               }
        }
        
-       return http_request_option_cache_ex(r, key, keylen, h, zval_copy(type, *zoption));
+       return NULL;
 }
 /* }}} */
 
@@ -1049,19 +1041,10 @@ static inline zval *_http_request_option_cache_ex(http_request *r, char *key, si
 {
        ZVAL_ADDREF(opt);
        
-#ifdef ZEND_ENGINE_2
        if (h) {
-               _zend_hash_quick_add_or_update(&r->_cache.options, key, keylen, h, &opt, sizeof(zval *), NULL, 
-                       zend_hash_quick_exists(&r->_cache.options, key, keylen, h)?HASH_UPDATE:HASH_ADD ZEND_FILE_LINE_CC);
-       }
-       else
-#endif
-       {
-               if (zend_hash_exists(&r->_cache.options, key, keylen)) {
-                       zend_hash_update(&r->_cache.options, key, keylen, &opt, sizeof(zval *), NULL);
-               } else {
-                       zend_hash_add(&r->_cache.options, key, keylen, &opt, sizeof(zval *), NULL);
-               }
+               zend_hash_quick_update(&r->_cache.options, key, keylen, h, &opt, sizeof(zval *), NULL);
+       } else {
+               zend_hash_update(&r->_cache.options, key, keylen, &opt, sizeof(zval *), NULL);
        }
        
        return opt;
index efb29fa..a380125 100644 (file)
@@ -744,7 +744,7 @@ STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this
 static int apply_pretty_key(void *pDest, int num_args, va_list args, zend_hash_key *hash_key)
 {
        if (hash_key->nKeyLength > 1) {
-               hash_key->h = zend_get_hash_value(pretty_key(hash_key->arKey, hash_key->nKeyLength - 1, 1, 0), hash_key->nKeyLength);
+               hash_key->h = zend_hash_func(pretty_key(hash_key->arKey, hash_key->nKeyLength - 1, 1, 0), hash_key->nKeyLength);
        }
        return ZEND_HASH_APPLY_KEEP;
 }
index 6844dd2..3a4f88b 100644 (file)
@@ -4,8 +4,6 @@
 #ifndef _PHPSTR_H_
 #define _PHPSTR_H_
 
-#include "php.h"
-
 #ifndef PHPSTR_DEFAULT_SIZE
 #      define PHPSTR_DEFAULT_SIZE 256
 #endif
 #ifndef pemalloc
 #      define pemalloc(s,p)    malloc(s)
 #      define pefree(x,p)              free(x)
-#      define perealloc(x,s,p) erealloc(x,s)
+#      define perealloc(x,s,p) realloc(x,s)
 #      define perealloc_recoverable perealloc
+#      define ecalloc calloc
+static inline void *estrndup(void *p, size_t s)
+{
+       char *r = (char *) malloc(s+1);
+       if (r) memcpy((void *) r, p, s), r[s] = '\0';
+       return (void *) r;
+}
 #endif
 
 #if defined(PHP_WIN32)