]> granicus.if.org Git - php/commitdiff
- Fix a nasty bug in the hash, introduced in the recent migration to macros
authorZeev Suraski <zeev@php.net>
Sat, 19 Feb 2000 19:21:45 +0000 (19:21 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 19 Feb 2000 19:21:45 +0000 (19:21 +0000)
- Make array_init() and friends trackable

Zend/zend_API.c
Zend/zend_API.h
Zend/zend_fast_cache.h
Zend/zend_hash.c

index 8e5cd4acad7153a8cae17d4e2e472fcb299cb5ae..d7c5f2761fda7322696ce74146012f3cbdf01dba 100644 (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);
 }
 
 
index 6222823ed9f0abed21245c0d5db84f402ea92a93..bab5304edcbc0efe3a0c2f47a69d4426e8fa6fa6 100644 (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));
index f62f0ee12a9f23c5b3c25c7a82fefb42b630c2ae..2f0f73c13a278c78bb229a47d2d092e38075803b 100644 (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 */
 
 /*
index b4be2f6cdae823355ac617c40090e4f3a2f1aa28..ac7e6f7f620c75fe6afe581f1862f13f4f444ca0 100644 (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;                                                                            \