X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_std_defs.h;h=558a8ec8d5b53a6fe0e2c02e28d29597ad08fb76;hp=c7646b7cd857e6d30158fc7ed163d5e9db78ebd3;hb=0ad0ac95cc4c97d7978421bd797282648168fbd3;hpb=19bdceaf74694339a5b6311a4144c1af5468f87a diff --git a/php_http_std_defs.h b/php_http_std_defs.h index c7646b7..558a8ec 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -66,17 +66,17 @@ typedef int STATUS; RETVAL_OBJECT(o); \ return #define RETVAL_OBJVAL(ov) \ - ZVAL_OBJVAL(return_value, ov) + ZVAL_OBJVAL(return_value, ov) \ + if (Z_OBJ_HT_P(return_value)->add_ref) { \ + Z_OBJ_HT_P(return_value)->add_ref(return_value TSRMLS_CC); \ + } #define RETURN_OBJVAL(ov) \ RETVAL_OBJVAL(ov); \ return #define ZVAL_OBJVAL(zv, ov) \ (zv)->type = IS_OBJECT; \ - (zv)->value.obj = (ov); \ - if (Z_OBJ_HT_P(zv)->add_ref) { \ - Z_OBJ_HT_P(zv)->add_ref((zv) TSRMLS_CC); \ - } - + (zv)->value.obj = (ov); + /* function accepts no args */ #define NO_ARGS \ if (ZEND_NUM_ARGS()) { \ @@ -129,24 +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_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) @@ -156,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; \ @@ -190,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); \ @@ -202,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); \ @@ -211,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); \