Skip to content

Commit f962a35

Browse files
author
Andrei Zmievski
committed
Added zend_set_hash_symbol() function.
1 parent 0a276c2 commit f962a35

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

Zend/zend_API.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,3 +836,24 @@ ZEND_API zend_module_entry *zend_get_module(int module_number)
836836
return NULL;
837837
}
838838
}
839+
840+
ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
841+
int is_ref, int num_symbol_tables, ...)
842+
{
843+
HashTable *symbol_table;
844+
va_list symbol_table_list;
845+
846+
if (num_symbol_tables <= 0) return FAILURE;
847+
848+
symbol->is_ref = is_ref;
849+
symbol->refcount = 0;
850+
851+
va_start(symbol_table_list, num_symbol_tables);
852+
while(num_symbol_tables-- > 0) {
853+
symbol_table = va_arg(symbol_table_list, HashTable *);
854+
zend_hash_update_ptr(symbol_table, name, name_length + 1, symbol, sizeof(zval *), NULL);
855+
zval_add_ref(&symbol);
856+
}
857+
va_end(symbol_table_list);
858+
return SUCCESS;
859+
}

Zend/zend_API.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ ZEND_API int add_property_double(zval *arg, char *key, double d);
132132
ZEND_API int add_property_string(zval *arg, char *key, char *str, int duplicate);
133133
ZEND_API int add_property_stringl(zval *arg, char *key, char *str, uint length, int duplicate);
134134

135+
ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
136+
int is_ref, int num_symbol_tables, ...);
137+
135138
#define add_method(arg,key,method) add_assoc_function((arg),(key),(method))
136139

137140
#define RETVAL_RESOURCE(l) { \
@@ -279,7 +282,7 @@ ZEND_API int add_property_stringl(zval *arg, char *key, char *str, uint length,
279282

280283
#define HASH_OF(p) ((p)->type==IS_ARRAY ? (p)->value.ht : (((p)->type==IS_OBJECT ? (p)->value.obj.properties : NULL)))
281284

282-
#endif /* _ZEND_API_H */
285+
#endif /* _ZEND_API_H */
283286

284287
/*
285288
* Local variables:

Zend/zend_hash.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ ZEND_API int zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, void
100100

101101
ZEND_API int zend_hash_pointer_update(HashTable *ht, char *arKey, uint nKeyLength, void *pData);
102102

103-
104103
typedef struct _zend_hash_key {
105104
char *arKey;
106105
uint nKeyLength;

0 commit comments

Comments
 (0)