X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_std_defs.h;h=558a8ec8d5b53a6fe0e2c02e28d29597ad08fb76;hp=40dc8c769e1b0ec00ca1b6e7364652697513de85;hb=0ad0ac95cc4c97d7978421bd797282648168fbd3;hpb=602fe384803e6f489c6e551722fff770e80ebf2d diff --git a/php_http_std_defs.h b/php_http_std_defs.h index 40dc8c7..558a8ec 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -129,31 +129,31 @@ typedef int STATUS; STD_PHP_INI_ENTRY_EX(entry, default, scope, updater, global, zend_http_globals, http_globals, displayer) /* {{{ arrays */ -#define FOREACH_VAL(array, val) FOREACH_HASH_VAL(Z_ARRVAL_P(array), val) -#define FOREACH_HASH_VAL(hash, val) \ - for ( zend_hash_internal_pointer_reset(hash); \ - zend_hash_get_current_data(hash, (void **) &val) == SUCCESS; \ - zend_hash_move_forward(hash)) - -#define FOREACH_KEY(array, strkey, numkey) FOREACH_HASH_KEY(Z_ARRVAL_P(array), strkey, numkey) -#define FOREACH_HASH_KEY(hash, strkey, numkey) \ - for ( zend_hash_internal_pointer_reset(hash); \ - zend_hash_get_current_key(hash, &strkey, &numkey, 0) != HASH_KEY_NON_EXISTANT; \ - zend_hash_move_forward(hash)) \ - -#define FOREACH_KEYVAL(array, strkey, numkey, val) FOREACH_HASH_KEYVAL(Z_ARRVAL_P(array), strkey, numkey, val) -#define FOREACH_HASH_KEYVAL(hash, strkey, numkey, val) \ - for ( zend_hash_internal_pointer_reset(hash); \ - zend_hash_get_current_key(hash, &strkey, &numkey, 0) != HASH_KEY_NON_EXISTANT && \ - zend_hash_get_current_data(hash, (void **) &val) == SUCCESS; \ - zend_hash_move_forward(hash)) - -#define FOREACH_KEYLENVAL(array, strkey, keylen, numkey, val) FOREACH_HASH_KEYVAL(Z_ARRVAL_P(array), strkey, keylen, numkey, val) -#define FOREACH_HASH_KEYLENVAL(hash, strkey, keylen, numkey, val) \ - for ( zend_hash_internal_pointer_reset(hash); \ - zend_hash_get_current_key_ex(hash, &strkey, &keylen, &numkey, 0, NULL) != HASH_KEY_NON_EXISTANT && \ - zend_hash_get_current_data(hash, (void **) &val) == SUCCESS; \ - zend_hash_move_forward(hash)) +#define FOREACH_VAL(pos, array, val) FOREACH_HASH_VAL(pos, Z_ARRVAL_P(array), val) +#define FOREACH_HASH_VAL(pos, hash, val) \ + for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \ + zend_hash_get_current_data_ex(hash, (void **) &val, &pos) == SUCCESS; \ + zend_hash_move_forward_ex(hash, &pos)) + +#define FOREACH_KEY(pos, array, strkey, numkey) FOREACH_HASH_KEY(pos, Z_ARRVAL_P(array), strkey, numkey) +#define FOREACH_HASH_KEY(pos, hash, strkey, numkey) \ + for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \ + zend_hash_get_current_key_ex(hash, &strkey, NULL, &numkey, 0, &pos) != HASH_KEY_NON_EXISTANT; \ + zend_hash_move_forward_ex(hash, &pos)) \ + +#define FOREACH_KEYVAL(pos, array, strkey, numkey, val) FOREACH_HASH_KEYVAL(pos, Z_ARRVAL_P(array), strkey, numkey, val) +#define FOREACH_HASH_KEYVAL(pos, hash, strkey, numkey, val) \ + for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \ + zend_hash_get_current_key_ex(hash, &strkey, NULL, &numkey, 0, &pos) != HASH_KEY_NON_EXISTANT && \ + zend_hash_get_current_data_ex(hash, (void **) &val, &pos) == SUCCESS; \ + zend_hash_move_forward_ex(hash, &pos)) + +#define FOREACH_KEYLENVAL(pos, array, strkey, keylen, numkey, val) FOREACH_HASH_KEYVAL(pos, Z_ARRVAL_P(array), strkey, keylen, numkey, val) +#define FOREACH_HASH_KEYLENVAL(pos, hash, strkey, keylen, numkey, val) \ + for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \ + zend_hash_get_current_key_ex(hash, &strkey, &keylen, &numkey, 0, &pos) != HASH_KEY_NON_EXISTANT && \ + zend_hash_get_current_data_ex(hash, (void **) &val, &pos) == SUCCESS; \ + zend_hash_move_forward_ex(hash, &pos)) #define array_copy(src, dst) zend_hash_copy(Z_ARRVAL_P(dst), Z_ARRVAL_P(src), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)) #define array_merge(src, dst) zend_hash_merge(Z_ARRVAL_P(dst), Z_ARRVAL_P(src), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *), 1) @@ -163,11 +163,12 @@ typedef int STATUS; uint klen; \ char *key = NULL; \ zval **data; \ + HashPosition pos; \ \ - for ( zend_hash_internal_pointer_reset(Z_ARRVAL_P(src)); \ - zend_hash_get_current_key_ex(Z_ARRVAL_P(src), &key, &klen, &idx, 0, NULL) != HASH_KEY_NON_EXISTANT && \ - zend_hash_get_current_data(Z_ARRVAL_P(src), (void **) &data) == SUCCESS; \ - zend_hash_move_forward(Z_ARRVAL_P(src))) \ + for ( zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(src), &pos); \ + zend_hash_get_current_key_ex(Z_ARRVAL_P(src), &key, &klen, &idx, 0, &pos) != HASH_KEY_NON_EXISTANT && \ + zend_hash_get_current_data_ex(Z_ARRVAL_P(src), (void **) &data, &pos) == SUCCESS; \ + zend_hash_move_forward_ex(Z_ARRVAL_P(src), &pos)) \ { \ if (key) { \ zval **tmp; \ @@ -197,6 +198,7 @@ typedef int STATUS; # define HTTP_REGISTER_CLASS_EX(classname, name, parent, flags) \ { \ zend_class_entry ce; \ + memset(&ce, 0, sizeof(zend_class_entry)); \ INIT_CLASS_ENTRY(ce, #classname, name## _fe); \ ce.create_object = _ ##name## _new; \ name## _ce = zend_register_internal_class_ex(&ce, parent, NULL TSRMLS_CC); \ @@ -209,6 +211,7 @@ typedef int STATUS; # define HTTP_REGISTER_CLASS(classname, name, parent, flags) \ { \ zend_class_entry ce; \ + memset(&ce, 0, sizeof(zend_class_entry)); \ INIT_CLASS_ENTRY(ce, #classname, name## _fe); \ ce.create_object = NULL; \ name## _ce = zend_register_internal_class_ex(&ce, parent, NULL TSRMLS_CC); \ @@ -218,6 +221,7 @@ typedef int STATUS; # define HTTP_REGISTER_EXCEPTION(classname, cename, parent) \ { \ zend_class_entry ce; \ + memset(&ce, 0, sizeof(zend_class_entry)); \ INIT_CLASS_ENTRY(ce, #classname, NULL); \ ce.create_object = NULL; \ cename = zend_register_internal_class_ex(&ce, parent, NULL TSRMLS_CC); \