mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
- Fix a nasty bug in the hash, introduced in the recent migration to macros
- Make array_init() and friends trackable
This commit is contained in:
parent
eb9d799876
commit
ceba50b6ed
@ -186,9 +186,9 @@ ZEND_API void wrong_param_count()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZEND_API inline int array_init(zval *arg)
|
ZEND_API inline int _array_init(zval *arg ZEND_FILE_LINE_DC)
|
||||||
{
|
{
|
||||||
ALLOC_HASHTABLE(arg->value.ht);
|
ALLOC_HASHTABLE_REL(arg->value.ht);
|
||||||
|
|
||||||
if (!arg->value.ht || zend_hash_init(arg->value.ht, 0, NULL, ZVAL_PTR_DTOR, 0)) {
|
if (!arg->value.ht || zend_hash_init(arg->value.ht, 0, NULL, ZVAL_PTR_DTOR, 0)) {
|
||||||
zend_error(E_CORE_ERROR, "Cannot allocate memory for array");
|
zend_error(E_CORE_ERROR, "Cannot allocate memory for array");
|
||||||
@ -199,7 +199,7 @@ ZEND_API inline int array_init(zval *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZEND_API inline int object_init_ex(zval *arg, zend_class_entry *class_type)
|
ZEND_API inline int _object_init_ex(zval *arg, zend_class_entry *class_type ZEND_FILE_LINE_DC)
|
||||||
{
|
{
|
||||||
zval *tmp;
|
zval *tmp;
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ ZEND_API inline int object_init_ex(zval *arg, zend_class_entry *class_type)
|
|||||||
class_type->constants_updated = 1;
|
class_type->constants_updated = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLOC_HASHTABLE(arg->value.obj.properties);
|
ALLOC_HASHTABLE_REL(arg->value.obj.properties);
|
||||||
zend_hash_init(arg->value.obj.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
|
zend_hash_init(arg->value.obj.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||||
zend_hash_copy(arg->value.obj.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
zend_hash_copy(arg->value.obj.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
||||||
arg->type = IS_OBJECT;
|
arg->type = IS_OBJECT;
|
||||||
@ -217,9 +217,9 @@ ZEND_API inline int object_init_ex(zval *arg, zend_class_entry *class_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZEND_API inline int object_init(zval *arg)
|
ZEND_API inline int _object_init(zval *arg ZEND_FILE_LINE_DC)
|
||||||
{
|
{
|
||||||
return object_init_ex(arg, &zend_standard_class_def);
|
return _object_init_ex(arg, &zend_standard_class_def ZEND_FILE_LINE_CC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,9 +90,12 @@ ZEND_API void wrong_param_count(void);
|
|||||||
|
|
||||||
ZEND_API int zend_startup_module(zend_module_entry *module);
|
ZEND_API int zend_startup_module(zend_module_entry *module);
|
||||||
|
|
||||||
ZEND_API int array_init(zval *arg);
|
#define array_init(arg) _array_init((arg) ZEND_FILE_LINE_CC)
|
||||||
ZEND_API int object_init(zval *arg);
|
#define object_init(arg) _object_init((arg) ZEND_FILE_LINE_CC)
|
||||||
ZEND_API int object_init_ex(zval *arg, zend_class_entry *ce);
|
#define object_init_ex(arg, ce) _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC)
|
||||||
|
ZEND_API int _array_init(zval *arg ZEND_FILE_LINE_DC);
|
||||||
|
ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC);
|
||||||
|
ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC);
|
||||||
|
|
||||||
/* no longer supported */
|
/* no longer supported */
|
||||||
ZEND_API int add_assoc_function(zval *arg, char *key,void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
|
ZEND_API int add_assoc_function(zval *arg, char *key,void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
|
||||||
|
@ -78,6 +78,12 @@ typedef struct _zend_fast_cache_list_entry {
|
|||||||
AG(fast_cache_list_head)[fc_type] = (zend_fast_cache_list_entry *) (p); \
|
AG(fast_cache_list_head)[fc_type] = (zend_fast_cache_list_entry *) (p); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ZEND_FAST_ALLOC_REL(p, type, fc_type) \
|
||||||
|
ZEND_FAST_ALLOC(p, type, fc_type)
|
||||||
|
|
||||||
|
#define ZEND_FAST_FREE_REL(p, fc_type) \
|
||||||
|
ZEND_FAST_FREE(p, fc_type)
|
||||||
|
|
||||||
|
|
||||||
#else /* !ZEND_ENABLE_FAST_CACHE */
|
#else /* !ZEND_ENABLE_FAST_CACHE */
|
||||||
|
|
||||||
@ -87,6 +93,12 @@ typedef struct _zend_fast_cache_list_entry {
|
|||||||
#define ZEND_FAST_FREE(p, fc_type) \
|
#define ZEND_FAST_FREE(p, fc_type) \
|
||||||
efree(p)
|
efree(p)
|
||||||
|
|
||||||
|
#define ZEND_FAST_ALLOC_REL(p, type, fc_type) \
|
||||||
|
(p) = (type *) emalloc_rel(sizeof(type))
|
||||||
|
|
||||||
|
#define ZEND_FAST_FREE_REL(p, fc_type) \
|
||||||
|
efree_rel(p)
|
||||||
|
|
||||||
#endif /* ZEND_ENABLE_FAST_CACHE */
|
#endif /* ZEND_ENABLE_FAST_CACHE */
|
||||||
|
|
||||||
|
|
||||||
@ -99,13 +111,25 @@ typedef struct _zend_fast_cache_list_entry {
|
|||||||
#define FREE_ZVAL(z) \
|
#define FREE_ZVAL(z) \
|
||||||
ZEND_FAST_FREE(z, ZVAL_CACHE_LIST)
|
ZEND_FAST_FREE(z, ZVAL_CACHE_LIST)
|
||||||
|
|
||||||
|
#define ALLOC_ZVAL_REL(z) \
|
||||||
|
ZEND_FAST_ALLOC_REL(z, zval, ZVAL_CACHE_LIST)
|
||||||
|
|
||||||
|
#define FREE_ZVAL_REL(z) \
|
||||||
|
ZEND_FAST_FREE_REL(z, ZVAL_CACHE_LIST)
|
||||||
|
|
||||||
/* fast cache for HashTable's */
|
/* fast cache for HashTable's */
|
||||||
#define ALLOC_HASHTABLE(b) \
|
#define ALLOC_HASHTABLE(ht) \
|
||||||
ZEND_FAST_ALLOC(b, HashTable, HASHTABLE_CACHE_LIST)
|
ZEND_FAST_ALLOC(ht, HashTable, HASHTABLE_CACHE_LIST)
|
||||||
|
|
||||||
#define FREE_HASHTABLE(ht) \
|
#define FREE_HASHTABLE(ht) \
|
||||||
ZEND_FAST_FREE(ht, HASHTABLE_CACHE_LIST)
|
ZEND_FAST_FREE(ht, HASHTABLE_CACHE_LIST)
|
||||||
|
|
||||||
|
#define ALLOC_HASHTABLE_REL(ht) \
|
||||||
|
ZEND_FAST_ALLOC_REL(ht, HashTable, HASHTABLE_CACHE_LIST)
|
||||||
|
|
||||||
|
#define FREE_HASHTABLE_REL(ht) \
|
||||||
|
ZEND_FAST_FREE_REL(ht, HASHTABLE_CACHE_LIST)
|
||||||
|
|
||||||
#endif /* _ZEND_FAST_CACHE_H */
|
#endif /* _ZEND_FAST_CACHE_H */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
#define HT_OK 0
|
#define HT_OK 0
|
||||||
|
|
||||||
static void _zend_is_inconsistent(HashTable *ht, char *file, int line)
|
static void _zend_is_inconsistent(HashTable *ht, char *file, int line)
|
||||||
{
|
{
|
||||||
switch (ht->inconsistent) {
|
switch (ht->inconsistent) {
|
||||||
case HT_IS_DESTROYING:
|
case HT_IS_DESTROYING:
|
||||||
zend_error(E_CORE_ERROR, "ht=%08x is destroying in %s:%d", ht, file, line);
|
zend_error(E_CORE_ERROR, "ht=%08x is destroying in %s:%d", ht, file, line);
|
||||||
@ -136,7 +136,7 @@ ZEND_API ulong hashpjw(char *arKey, uint nKeyLength)
|
|||||||
#define UPDATE_DATA(ht, p, pData, nDataSize) \
|
#define UPDATE_DATA(ht, p, pData, nDataSize) \
|
||||||
if (flag & HASH_ADD_PTR) { \
|
if (flag & HASH_ADD_PTR) { \
|
||||||
if (!(p)->pDataPtr) { \
|
if (!(p)->pDataPtr) { \
|
||||||
pefree(p, (ht)->persistent); \
|
pefree((p)->pData, (ht)->persistent); \
|
||||||
} \
|
} \
|
||||||
(p)->pDataPtr = pData; \
|
(p)->pDataPtr = pData; \
|
||||||
(p)->pData = &(p)->pDataPtr; \
|
(p)->pData = &(p)->pDataPtr; \
|
||||||
|
Loading…
Reference in New Issue
Block a user