From dda059708f20f30baca51d72f9d2beabdc6db2a7 Mon Sep 17 00:00:00 2001 From: Andrei Zmievski Date: Fri, 4 Aug 2006 21:05:59 +0000 Subject: [PATCH] Add add_assoc_zstr_ex() and related. --- Zend/zend_API.c | 20 ++++++++++++++++++++ Zend/zend_API.h | 6 +++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 0a67bc9763..31ea41ae9e 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1504,6 +1504,26 @@ ZEND_API int add_u_assoc_unicodel_ex(zval *arg, zend_uchar type, zstr key, uint return zend_u_symtable_update(Z_ARRVAL_P(arg), type, key, key_len, (void *) &tmp, sizeof(zval *), NULL); } +ZEND_API int add_assoc_zstr_ex(zval *arg, char *key, uint key_len, zend_uchar type, zstr str, int duplicate) +{ + zval *tmp; + + MAKE_STD_ZVAL(tmp); + ZVAL_ZSTR(tmp, str, type, duplicate); + + return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL); +} + +ZEND_API int add_assoc_zstrl_ex(zval *arg, char *key, uint key_len, zend_uchar type, zstr str, uint length, int duplicate) +{ + zval *tmp; + + MAKE_STD_ZVAL(tmp); + ZVAL_ZSTRL(tmp, str, length, type, duplicate); + + return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL); +} + ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value) { return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &value, sizeof(zval *), NULL); diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 57297f1a90..6d8353902a 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -332,6 +332,8 @@ ZEND_API int add_assoc_string_ex(zval *arg, char *key, uint key_len, char *str, ZEND_API int add_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate); ZEND_API int add_assoc_unicode_ex(zval *arg, char *key, uint key_len, UChar *str, int duplicate); ZEND_API int add_assoc_unicodel_ex(zval *arg, char *key, uint key_len, UChar *str, uint length, int duplicate); +ZEND_API int add_assoc_zstr_ex(zval *arg, char *key, uint key_len, zend_uchar str_type, zstr str, int duplicate); +ZEND_API int add_assoc_zstrl_ex(zval *arg, char *key, uint key_len, zend_uchar str_type, zstr str, uint str_len, int duplicate); ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value); #define ZSTR_DUPLICATE (1<<0) @@ -412,6 +414,8 @@ ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value); #define add_assoc_stringl(__arg, __key, __str, __length, __duplicate) add_assoc_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate) #define add_assoc_unicode(__arg, __key, __str, __duplicate) add_assoc_unicode_ex(__arg, __key, strlen(__key)+1, __str, __duplicate) #define add_assoc_unicodel(__arg, __key, __str, __length, __duplicate) add_assoc_unicodel_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate) +#define add_assoc_zstr(__arg, __key, __type, __str, __duplicate) add_assoc_zstr_ex(__arg, __key, strlen(__key)+1, __type, __str, __duplicate) +#define add_assoc_zstrl(__arg, __key, __type, __str, __length, __duplicate) add_assoc_zstrl_ex(__arg, __key, strlen(__key)+1, __type, __str, __length, __duplicate) #define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key)+1, __value) #define add_assoc_rt_string(__arg, __key, __str, __duplicate) add_assoc_rt_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate) #define add_assoc_rt_stringl(__arg, __key, __str, __length, __duplicate) add_assoc_rt_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate) @@ -853,7 +857,7 @@ END_EXTERN_C() #define ZVAL_ZSTR(z, zs, type, duplicate) { \ zstr __s=(zs); \ - Z_UNILEN_P(z) = (type==IS_UNICODE)?u_strlen(__s):strlen(__s); \ + Z_UNILEN_P(z) = (type==IS_UNICODE)?u_strlen(__s.u):strlen(__s.s); \ Z_UNIVAL_P(z) = ZSTR(duplicate? \ ((type==IS_UNICODE)? \ (void*)eustrndup(__s.u, Z_UNILEN_P(z)) \ -- 2.50.1