diff options
author | Zeev Suraski <zeev@php.net> | 2000-02-19 19:21:45 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2000-02-19 19:21:45 +0000 |
commit | ceba50b6edc03128c29dfa96bfcb93d299654710 (patch) | |
tree | e4b7da9e953001a1d926c521d38ee16ca36daf25 | |
parent | eb9d7998769d6bafcdf28b61257ed16528b5d7b2 (diff) | |
download | php-git-ceba50b6edc03128c29dfa96bfcb93d299654710.tar.gz |
- Fix a nasty bug in the hash, introduced in the recent migration to macros
- Make array_init() and friends trackable
-rw-r--r-- | Zend/zend_API.c | 12 | ||||
-rw-r--r-- | Zend/zend_API.h | 9 | ||||
-rw-r--r-- | Zend/zend_fast_cache.h | 28 | ||||
-rw-r--r-- | Zend/zend_hash.c | 4 |
4 files changed, 40 insertions, 13 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 8e5cd4acad..d7c5f2761f 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -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); } diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 6222823ed9..bab5304edc 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -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)); diff --git a/Zend/zend_fast_cache.h b/Zend/zend_fast_cache.h index f62f0ee12a..2f0f73c13a 100644 --- a/Zend/zend_fast_cache.h +++ b/Zend/zend_fast_cache.h @@ -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 */ /* diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index b4be2f6cda..ac7e6f7f62 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -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; \ |