cvs: php4 /ext/standard array.c
| From: | Ilia Alshanetsky | Date: | Tue, 05 Nov 2002 16:19:20 +0000 |
| Subject: | cvs: php4 /ext/standard array.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-15830@lists.php.net to get a copy of this message | ||
iliaa Tue Nov 5 11:19:20 2002 EDT
Modified files:
/php4/ext/standard array.c
Log:
Fixed a memory leak in array_fill().
The refcount hack is now done for ZE1 only and is slightly faster then the
original.
After this patch array_fill() can consistently create arrays with >65k elements.
Index: php4/ext/standard/array.c
diff -u php4/ext/standard/array.c:1.197 php4/ext/standard/array.c:1.198
--- php4/ext/standard/array.c:1.197 Thu Oct 10 15:24:45 2002
+++ php4/ext/standard/array.c Tue Nov 5 11:19:19 2002
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.197 2002/10/10 19:24:45 sterling Exp $ */
+/* $Id: array.c,v 1.198 2002/11/05 16:19:19 iliaa Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -1397,11 +1397,14 @@
}
newval = *val;
while (i--) {
- if (!(i%62000)) {
+#ifndef ZEND_ENGINE_2
+ if (newval->refcount >= 62000) {
MAKE_STD_ZVAL(newval);
*newval = **val;
zval_copy_ctor(newval);
+ newval->refcount = 0;
}
+#endif
zval_add_ref(&newval);
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &newval, sizeof(zval *), NULL);
}