1999-04-08 02:10:10 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2007-01-01 17:36:18 +08:00
|
|
|
| Copyright (c) 1998-2007 Zend Technologies Ltd. (http://www.zend.com) |
|
1999-04-08 02:10:10 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2001-12-11 23:16:21 +08:00
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
1999-07-16 22:58:16 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-11 04:04:29 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
2001-12-11 23:16:21 +08:00
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
1999-07-16 22:58:16 +08:00
|
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@zend.com so we can mail you a copy immediately. |
|
1999-04-08 02:10:10 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Andi Gutmans <andi@zend.com> |
|
|
|
|
| Zeev Suraski <zeev@zend.com> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2003-02-01 09:49:15 +08:00
|
|
|
/* $Id$ */
|
1999-07-16 22:58:16 +08:00
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "zend.h"
|
|
|
|
#include "zend_API.h"
|
|
|
|
#include "zend_globals.h"
|
|
|
|
#include "zend_constants.h"
|
|
|
|
#include "zend_list.h"
|
|
|
|
|
|
|
|
|
2004-09-27 04:03:54 +08:00
|
|
|
ZEND_API void _zval_dtor_func(zval *zvalue ZEND_FILE_LINE_DC)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
2002-11-30 19:20:25 +08:00
|
|
|
switch (zvalue->type & ~IS_CONSTANT_INDEX) {
|
1999-04-08 02:10:10 +08:00
|
|
|
case IS_STRING:
|
|
|
|
case IS_CONSTANT:
|
2001-07-16 23:48:31 +08:00
|
|
|
CHECK_ZVAL_STRING_REL(zvalue);
|
1999-08-28 03:17:19 +08:00
|
|
|
STR_FREE_REL(zvalue->value.str.val);
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
2000-06-01 03:07:09 +08:00
|
|
|
case IS_ARRAY:
|
|
|
|
case IS_CONSTANT_ARRAY: {
|
2001-07-27 18:10:39 +08:00
|
|
|
TSRMLS_FETCH();
|
1999-04-08 02:10:10 +08:00
|
|
|
|
|
|
|
if (zvalue->value.ht && (zvalue->value.ht != &EG(symbol_table))) {
|
1999-07-10 04:43:59 +08:00
|
|
|
zend_hash_destroy(zvalue->value.ht);
|
1999-12-28 03:07:33 +08:00
|
|
|
FREE_HASHTABLE(zvalue->value.ht);
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-07-10 19:45:23 +08:00
|
|
|
case IS_OBJECT:
|
2002-03-16 00:26:17 +08:00
|
|
|
{
|
|
|
|
TSRMLS_FETCH();
|
|
|
|
|
|
|
|
Z_OBJ_HT_P(zvalue)->del_ref(zvalue TSRMLS_CC);
|
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
2002-03-16 00:26:17 +08:00
|
|
|
case IS_RESOURCE:
|
|
|
|
{
|
2001-07-30 12:54:16 +08:00
|
|
|
TSRMLS_FETCH();
|
|
|
|
|
|
|
|
/* destroy resource */
|
|
|
|
zend_list_delete(zvalue->value.lval);
|
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
|
|
|
case IS_LONG:
|
|
|
|
case IS_DOUBLE:
|
|
|
|
case IS_BOOL:
|
2000-01-04 21:22:58 +08:00
|
|
|
case IS_NULL:
|
1999-04-08 02:10:10 +08:00
|
|
|
default:
|
2000-01-18 01:33:37 +08:00
|
|
|
return;
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-25 01:32:47 +08:00
|
|
|
ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC)
|
|
|
|
{
|
|
|
|
switch (zvalue->type & ~IS_CONSTANT_INDEX) {
|
|
|
|
case IS_STRING:
|
|
|
|
case IS_CONSTANT:
|
|
|
|
CHECK_ZVAL_STRING_REL(zvalue);
|
2004-07-19 15:19:50 +08:00
|
|
|
free(zvalue->value.str.val);
|
2003-08-25 01:32:47 +08:00
|
|
|
break;
|
|
|
|
case IS_ARRAY:
|
|
|
|
case IS_CONSTANT_ARRAY:
|
|
|
|
case IS_OBJECT:
|
|
|
|
case IS_RESOURCE:
|
|
|
|
zend_error(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources");
|
|
|
|
break;
|
|
|
|
case IS_LONG:
|
|
|
|
case IS_DOUBLE:
|
|
|
|
case IS_BOOL:
|
|
|
|
case IS_NULL:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-21 22:45:10 +08:00
|
|
|
ZEND_API void zval_add_ref(zval **p)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
|
|
|
(*p)->refcount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-27 10:29:01 +08:00
|
|
|
ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
|
|
|
switch (zvalue->type) {
|
2001-07-30 12:54:16 +08:00
|
|
|
case IS_RESOURCE: {
|
|
|
|
TSRMLS_FETCH();
|
|
|
|
|
|
|
|
zend_list_addref(zvalue->value.lval);
|
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
|
|
|
case IS_BOOL:
|
|
|
|
case IS_LONG:
|
2000-01-04 21:22:58 +08:00
|
|
|
case IS_NULL:
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
2000-04-27 06:10:06 +08:00
|
|
|
case IS_CONSTANT:
|
1999-04-08 02:10:10 +08:00
|
|
|
case IS_STRING:
|
2001-07-16 23:48:31 +08:00
|
|
|
CHECK_ZVAL_STRING_REL(zvalue);
|
1999-08-28 18:18:54 +08:00
|
|
|
zvalue->value.str.val = (char *) estrndup_rel(zvalue->value.str.val, zvalue->value.str.len);
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
2000-06-01 03:07:09 +08:00
|
|
|
case IS_ARRAY:
|
|
|
|
case IS_CONSTANT_ARRAY: {
|
1999-04-08 02:10:10 +08:00
|
|
|
zval *tmp;
|
|
|
|
HashTable *original_ht = zvalue->value.ht;
|
2004-07-10 15:46:17 +08:00
|
|
|
HashTable *tmp_ht = NULL;
|
2001-07-27 18:10:39 +08:00
|
|
|
TSRMLS_FETCH();
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2001-05-12 21:55:49 +08:00
|
|
|
if (zvalue->value.ht == &EG(symbol_table)) {
|
2004-09-27 10:29:01 +08:00
|
|
|
return; /* do nothing */
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
2004-07-10 15:46:17 +08:00
|
|
|
ALLOC_HASHTABLE_REL(tmp_ht);
|
2006-10-03 19:10:33 +08:00
|
|
|
zend_hash_init(tmp_ht, zend_hash_num_elements(original_ht), NULL, ZVAL_PTR_DTOR, 0);
|
2004-07-10 15:46:17 +08:00
|
|
|
zend_hash_copy(tmp_ht, original_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
|
|
|
zvalue->value.ht = tmp_ht;
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
break;
|
2001-08-07 11:17:33 +08:00
|
|
|
case IS_OBJECT:
|
2002-03-16 00:26:17 +08:00
|
|
|
{
|
|
|
|
TSRMLS_FETCH();
|
2004-03-24 18:55:04 +08:00
|
|
|
Z_OBJ_HT_P(zvalue)->add_ref(zvalue TSRMLS_CC);
|
2002-03-16 00:26:17 +08:00
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ZEND_API int zend_print_variable(zval *var)
|
|
|
|
{
|
|
|
|
return zend_print_zval(var, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-08-29 05:43:24 +08:00
|
|
|
#if ZEND_DEBUG
|
2004-09-27 15:04:36 +08:00
|
|
|
ZEND_API void _zval_copy_ctor_wrapper(zval *zvalue)
|
1999-08-28 03:17:19 +08:00
|
|
|
{
|
2004-09-27 15:04:36 +08:00
|
|
|
zval_copy_ctor(zvalue);
|
1999-08-28 03:17:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-18 01:33:37 +08:00
|
|
|
ZEND_API void _zval_dtor_wrapper(zval *zvalue)
|
1999-08-28 03:17:19 +08:00
|
|
|
{
|
2000-01-18 01:33:37 +08:00
|
|
|
zval_dtor(zvalue);
|
1999-08-28 03:17:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-25 01:32:47 +08:00
|
|
|
ZEND_API void _zval_internal_dtor_wrapper(zval *zvalue)
|
|
|
|
{
|
|
|
|
zval_internal_dtor(zvalue);
|
|
|
|
}
|
|
|
|
|
1999-08-28 03:17:19 +08:00
|
|
|
|
2000-01-18 01:33:37 +08:00
|
|
|
ZEND_API void _zval_ptr_dtor_wrapper(zval **zval_ptr)
|
1999-08-28 03:17:19 +08:00
|
|
|
{
|
2000-01-18 02:45:46 +08:00
|
|
|
zval_ptr_dtor(zval_ptr);
|
1999-08-28 03:17:19 +08:00
|
|
|
}
|
2003-08-25 01:32:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
ZEND_API void _zval_internal_ptr_dtor_wrapper(zval **zval_ptr)
|
|
|
|
{
|
|
|
|
zval_internal_ptr_dtor(zval_ptr);
|
|
|
|
}
|
1999-08-28 03:17:19 +08:00
|
|
|
#endif
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
2003-02-01 09:49:15 +08:00
|
|
|
* indent-tabs-mode: t
|
1999-04-08 02:10:10 +08:00
|
|
|
* End:
|
|
|
|
*/
|