From: Andi Gutmans Date: Fri, 24 Mar 2000 11:12:30 +0000 (+0000) Subject: - Nuke hash_*_ptr functions X-Git-Tag: PHP-4.0-RC1~48 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6db18997bbcd4e930cb85d7f8668b5813e6cd0e0;p=php - Nuke hash_*_ptr functions --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 27e106de32..ecf62e0f39 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -939,7 +939,7 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length, va_start(symbol_table_list, num_symbol_tables); while(num_symbol_tables-- > 0) { symbol_table = va_arg(symbol_table_list, HashTable *); - zend_hash_update_ptr(symbol_table, name, name_length + 1, symbol, sizeof(zval *), NULL); + zend_hash_update(symbol_table, name, name_length + 1, &symbol, sizeof(zval *), NULL); zval_add_ref(&symbol); } va_end(symbol_table_list); diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 6a3ac1a3c0..9ae62e2502 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -280,7 +280,7 @@ ZEND_FUNCTION(each) } zend_hash_index_update(return_value->value.ht, 1, &entry, sizeof(zval *), NULL); entry->refcount++; - zend_hash_update_ptr(return_value->value.ht, "value", sizeof("value"), entry, sizeof(zval *), NULL); + zend_hash_update(return_value->value.ht, "value", sizeof("value"), &entry, sizeof(zval *), NULL); entry->refcount++; /* add the key elements */ diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 81d4878e21..4e77ca438d 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1857,7 +1857,7 @@ void do_fetch_global_or_static_variable(znode *varname, znode *static_assignment ALLOC_HASHTABLE(CG(active_op_array)->static_variables); zend_hash_init(CG(active_op_array)->static_variables, 2, NULL, ZVAL_PTR_DTOR, 0); } - zend_hash_update_ptr(CG(active_op_array)->static_variables, varname->u.constant.value.str.val, varname->u.constant.value.str.len+1, tmp, sizeof(zval *), NULL); + zend_hash_update(CG(active_op_array)->static_variables, varname->u.constant.value.str.val, varname->u.constant.value.str.len+1, &tmp, sizeof(zval *), NULL); } diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 3b1c05c2b5..0404b6537d 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -222,7 +222,7 @@ static inline zval **zend_fetch_property_address_inner(HashTable *ht, znode *op2 zval *new_zval = &EG(uninitialized_zval); new_zval->refcount++; - zend_hash_update_ptr(ht, prop_ptr->value.str.val, prop_ptr->value.str.len+1, new_zval, sizeof(zval *), (void **) &retval); + zend_hash_update(ht, prop_ptr->value.str.val, prop_ptr->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval); } break; EMPTY_SWITCH_DEFAULT_CASE() @@ -513,7 +513,7 @@ static void zend_fetch_var_address(znode *result, znode *op1, znode *op2, temp_v zval *new_zval = &EG(uninitialized_zval); new_zval->refcount++; - zend_hash_update_ptr(target_symbol_table, varname->value.str.val, varname->value.str.len+1, new_zval, sizeof(zval *), (void **) &retval); + zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval); } break; EMPTY_SWITCH_DEFAULT_CASE() @@ -567,7 +567,7 @@ fetch_string_dim: zval *new_zval = &EG(uninitialized_zval); new_zval->refcount++; - zend_hash_update_ptr(ht, offset_key, offset_key_length+1, new_zval, sizeof(zval *), (void **) &retval); + zend_hash_update(ht, offset_key, offset_key_length+1, &new_zval, sizeof(zval *), (void **) &retval); } break; } @@ -705,7 +705,7 @@ static void zend_fetch_dimension_address(znode *result, znode *op1, znode *op2, zval *new_zval = &EG(uninitialized_zval); new_zval->refcount++; - zend_hash_next_index_insert_ptr(container->value.ht, new_zval, sizeof(zval *), (void **) retval); + zend_hash_next_index_insert(container->value.ht, &new_zval, sizeof(zval *), (void **) retval); } else { *retval = zend_fetch_dimension_address_inner(container->value.ht, op2, Ts, type ELS_CC); } @@ -1614,8 +1614,9 @@ do_fcall_common: && object.ptr && fbc->type!=ZEND_OVERLOADED_FUNCTION) { zval **this_ptr; + zval *null_ptr = NULL; - zend_hash_update_ptr(function_state.function_symbol_table, "this", sizeof("this"), NULL, sizeof(zval *), (void **) &this_ptr); + zend_hash_update(function_state.function_symbol_table, "this", sizeof("this"), &null_ptr, sizeof(zval *), (void **) &this_ptr); if (!PZVAL_IS_REF(object.ptr)) { zend_error(E_WARNING,"Problem with method call. Report this bug\n"); } diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index be10cb0606..cd25435841 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -398,7 +398,7 @@ int call_user_function_ex(HashTable *function_table, zval *object, zval *functio ALLOC_ZVAL(dummy); INIT_ZVAL(*dummy); - zend_hash_update_ptr(EG(active_symbol_table), "this", sizeof("this"), dummy, sizeof(zval *), (void **) &this_ptr); + zend_hash_update(EG(active_symbol_table), "this", sizeof("this"), &dummy, sizeof(zval *), (void **) &this_ptr); zend_assign_to_variable_reference(NULL, this_ptr, &object, NULL ELS_CC); } original_return_value = EG(return_value_ptr_ptr); diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index a72778b6e1..073d511f6d 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -134,11 +134,11 @@ ZEND_API ulong hashpjw(char *arKey, uint nKeyLength) #define UPDATE_DATA(ht, p, pData, nDataSize) \ - if (flag & HASH_ADD_PTR) { \ + if (nDataSize == sizeof(void*)) { \ if (!(p)->pDataPtr) { \ pefree((p)->pData, (ht)->persistent); \ } \ - (p)->pDataPtr = pData; \ + (p)->pDataPtr = *(void **)pData; \ (p)->pData = &(p)->pDataPtr; \ } else { \ if ((p)->pDataPtr) { \ @@ -149,8 +149,8 @@ ZEND_API ulong hashpjw(char *arKey, uint nKeyLength) } #define INIT_DATA(ht, p, pData, nDataSize); \ - if (flag & HASH_ADD_PTR) { \ - (p)->pDataPtr = pData; \ + if (nDataSize == sizeof(void*)) { \ + (p)->pDataPtr = *(void **)pData; \ (p)->pData = &(p)->pDataPtr; \ } else { \ (p)->pData = (void *) pemalloc(nDataSize, (ht)->persistent); \ diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 370b560017..6347f21c56 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -29,7 +29,6 @@ #define HASH_UPDATE (1<<0) #define HASH_ADD (1<<1) #define HASH_NEXT_INSERT (1<<2) -#define HASH_ADD_PTR (1<<3) #define HASH_DEL_KEY 0 #define HASH_DEL_INDEX 1 @@ -89,26 +88,18 @@ ZEND_API int zend_hash_add_or_update(HashTable *ht, char *arKey, uint nKeyLength zend_hash_add_or_update(ht,arKey,nKeyLength,pData,nDataSize,pDest,HASH_UPDATE) #define zend_hash_add(ht,arKey,nKeyLength,pData,nDataSize,pDest) \ zend_hash_add_or_update(ht,arKey,nKeyLength,pData,nDataSize,pDest,HASH_ADD) -#define zend_hash_update_ptr(ht,arKey,nKeyLength,pData,nDataSize,pDest) \ - zend_hash_add_or_update(ht,arKey,nKeyLength,pData,0,pDest,(HASH_UPDATE|HASH_ADD_PTR)) -#define zend_hash_add_ptr(ht,arKey,nKeyLength,pData,nDataSize,pDest) \ - zend_hash_add_or_update(ht,arKey,nKeyLength,pData,nDataSize,pDest,(HASH_ADD|HASH_ADD_PTR)) ZEND_API int zend_hash_quick_add_or_update(HashTable *ht, char *arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest,int flag); #define zend_hash_quick_update(ht,arKey,nKeyLength,h,pData,nDataSize,pDest) \ zend_hash_quick_add_or_update(ht,arKey,nKeyLength,h,pData,nDataSize,pDest,HASH_UPDATE) #define zend_hash_quick_add(ht,arKey,nKeyLength,h,pData,nDataSize,pDest) \ zend_hash_quick_add_or_update(ht,arKey,nKeyLength,h,pData,nDataSize,pDest,HASH_ADD) -#define zend_hash_quick_update_ptr(ht,arKey,nKeyLength,h,pData,nDataSize,pDest) \ - zend_hash_quick_add_or_update(ht,arKey,nKeyLength,h,pData,0,pDest,HASH_UPDATE|HASH_ADD_PTR) ZEND_API int zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, void *pData, uint nDataSize, void **pDest, int flag); #define zend_hash_index_update(ht,h,pData,nDataSize,pDest) \ zend_hash_index_update_or_next_insert(ht,h,pData,nDataSize,pDest,HASH_UPDATE) #define zend_hash_next_index_insert(ht,pData,nDataSize,pDest) \ zend_hash_index_update_or_next_insert(ht,0,pData,nDataSize,pDest,HASH_NEXT_INSERT) -#define zend_hash_next_index_insert_ptr(ht,pData,nDataSize,pDest) \ - zend_hash_index_update_or_next_insert(ht,0,pData,nDataSize,pDest,HASH_NEXT_INSERT|HASH_ADD_PTR) typedef struct _zend_hash_key { char *arKey;