- 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:
Zeev Suraski 2000-02-19 19:21:45 +00:00
parent eb9d799876
commit ceba50b6ed
4 changed files with 40 additions and 13 deletions

View File

@ -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)) {
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;
@ -208,7 +208,7 @@ ZEND_API inline int object_init_ex(zval *arg, zend_class_entry *class_type)
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_copy(arg->value.obj.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
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);
}

View File

@ -90,9 +90,12 @@ ZEND_API void wrong_param_count(void);
ZEND_API int zend_startup_module(zend_module_entry *module);
ZEND_API int array_init(zval *arg);
ZEND_API int object_init(zval *arg);
ZEND_API int object_init_ex(zval *arg, zend_class_entry *ce);
#define array_init(arg) _array_init((arg) ZEND_FILE_LINE_CC)
#define object_init(arg) _object_init((arg) ZEND_FILE_LINE_CC)
#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 */
ZEND_API int add_assoc_function(zval *arg, char *key,void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));

View File

@ -78,6 +78,12 @@ typedef struct _zend_fast_cache_list_entry {
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 */
@ -87,6 +93,12 @@ typedef struct _zend_fast_cache_list_entry {
#define ZEND_FAST_FREE(p, fc_type) \
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 */
@ -99,13 +111,25 @@ typedef struct _zend_fast_cache_list_entry {
#define FREE_ZVAL(z) \
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 */
#define ALLOC_HASHTABLE(b) \
ZEND_FAST_ALLOC(b, HashTable, HASHTABLE_CACHE_LIST)
#define ALLOC_HASHTABLE(ht) \
ZEND_FAST_ALLOC(ht, HashTable, HASHTABLE_CACHE_LIST)
#define FREE_HASHTABLE(ht) \
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 */
/*

View File

@ -84,7 +84,7 @@
#define HT_OK 0
static void _zend_is_inconsistent(HashTable *ht, char *file, int line)
{
{
switch (ht->inconsistent) {
case HT_IS_DESTROYING:
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) \
if (flag & HASH_ADD_PTR) { \
if (!(p)->pDataPtr) { \
pefree(p, (ht)->persistent); \
pefree((p)->pData, (ht)->persistent); \
} \
(p)->pDataPtr = pData; \
(p)->pData = &(p)->pDataPtr; \