+----------------------------------------------------------------------+
| APC |
+----------------------------------------------------------------------+
- | Copyright (c) 2006 The PHP Group |
+ | Copyright (c) 2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
*/
-/* $Id: apc_compile.c,v 3.87.2.4 2008/03/28 21:05:14 rasmus Exp $ */
+/* $Id: apc_compile.c,v 3.87.2.8 2008/05/11 18:57:00 rasmus Exp $ */
#include "apc_compile.h"
#include "apc_globals.h"
static znode* my_copy_znode(znode*, znode*, apc_malloc_t, apc_free_t);
static zend_op* my_copy_zend_op(zend_op*, zend_op*, apc_malloc_t, apc_free_t);
static zend_function* my_copy_function(zend_function*, zend_function*, apc_malloc_t, apc_free_t);
-static zend_function_entry* my_copy_function_entry(zend_function_entry*, zend_function_entry*, apc_malloc_t, apc_free_t);
+static zend_function_entry* my_copy_function_entry(zend_function_entry*, const zend_function_entry*, apc_malloc_t, apc_free_t);
static zend_class_entry* my_copy_class_entry(zend_class_entry*, zend_class_entry*, apc_malloc_t, apc_free_t);
static HashTable* my_copy_hashtable_ex(HashTable*, HashTable*, ht_copy_fun_t, ht_free_fun_t, int, apc_malloc_t, apc_free_t, ht_check_copy_fun_t, ...);
#define my_copy_hashtable( dst, src, copy_fn, free_fn, holds_ptr, allocate, deallocate) \
static HashTable* my_copy_static_variables(zend_op_array* src, apc_malloc_t allocate, apc_free_t deallocate);
#ifdef ZEND_ENGINE_2
static zend_property_info* my_copy_property_info(zend_property_info* dst, zend_property_info* src, apc_malloc_t allocate, apc_free_t deallocate);
-static zend_arg_info* my_copy_arg_info_array(zend_arg_info*, zend_arg_info*, uint, apc_malloc_t, apc_free_t);
-static zend_arg_info* my_copy_arg_info(zend_arg_info*, zend_arg_info*, apc_malloc_t, apc_free_t);
+static zend_arg_info* my_copy_arg_info_array(zend_arg_info*, const zend_arg_info*, uint, apc_malloc_t, apc_free_t);
+static zend_arg_info* my_copy_arg_info(zend_arg_info*, const zend_arg_info*, apc_malloc_t, apc_free_t);
#endif
/*
* The "destroy" functions free the memory associated with a particular data
local_dst_alloc = 1;
}
+#ifdef ZEND_ENGINE_2_3
+ if(!(dst[0] = (zval*) allocate(sizeof(zval_gc_info)))) {
+ if(local_dst_alloc) deallocate(dst);
+ return NULL;
+ }
+
+ if(allocate == apc_php_malloc) {
+ GC_ZVAL_INIT(dst[0]);
+ }
+#else
if(!(dst[0] = (zval*) allocate(sizeof(zval)))) {
if(local_dst_alloc) deallocate(dst);
return NULL;
}
+#endif
if(!(dst_new = my_copy_zval(*dst, *src, allocate, deallocate))) {
if(local_dst_alloc) deallocate(dst);
return NULL;
*dst = dst_new;
}
- Z_SET_REFCOUNT_PP(dst, Z_REFCOUNT_PP(src));
- Z_SET_ISREF_TO_PP(dst, Z_ISREF_PP(src));
+ Z_SET_REFCOUNT_PP(dst, Z_REFCOUNT_PP((zval**)src));
+ Z_SET_ISREF_TO_PP(dst, Z_ISREF_PP((zval**)src));
return dst;
}
/* }}} */
/* {{{ my_copy_function_entry */
-static zend_function_entry* my_copy_function_entry(zend_function_entry* dst, zend_function_entry* src, apc_malloc_t allocate, apc_free_t deallocate)
+static zend_function_entry* my_copy_function_entry(zend_function_entry* dst, const zend_function_entry* src, apc_malloc_t allocate, apc_free_t deallocate)
{
int local_dst_alloc = 0;
assert(src != NULL);
return dst;
cleanup:
- if(dst->fname) deallocate(dst->fname);
+ if(dst->fname) deallocate((char*)dst->fname);
if(local_dst_alloc) deallocate(dst);
return NULL;
}
/* }}} */
/* {{{ my_copy_arg_info_array */
-static zend_arg_info* my_copy_arg_info_array(zend_arg_info* dst, zend_arg_info* src, uint num_args, apc_malloc_t allocate, apc_free_t deallocate)
+static zend_arg_info* my_copy_arg_info_array(zend_arg_info* dst, const zend_arg_info* src, uint num_args, apc_malloc_t allocate, apc_free_t deallocate)
{
int local_dst_alloc = 0;
int i = 0;
/* }}} */
/* {{{ my_copy_arg_info */
-static zend_arg_info* my_copy_arg_info(zend_arg_info* dst, zend_arg_info* src, apc_malloc_t allocate, apc_free_t deallocate)
+static zend_arg_info* my_copy_arg_info(zend_arg_info* dst, const zend_arg_info* src, apc_malloc_t allocate, apc_free_t deallocate)
{
int local_dst_alloc = 0;
return dst;
cleanup:
- if(dst->name) deallocate(dst->name);
- if(dst->class_name) deallocate(dst->name);
+ if(dst->name) deallocate((char*)dst->name);
+ if(dst->class_name) deallocate((char*)dst->class_name);
if(local_dst_alloc) deallocate(dst);
return NULL;
}
for (i = 0; i < n; i++) {
- if(!my_copy_function_entry(&dst->builtin_functions[i],
+ if(!my_copy_function_entry((zend_function_entry*)(&dst->builtin_functions[i]),
&src->builtin_functions[i],
allocate, deallocate)) {
int ii;
- for(ii=i-1; i>=0; i--) my_destroy_function_entry(&dst->builtin_functions[ii], deallocate);
+ for(ii=i-1; ii>=0; ii--) my_destroy_function_entry((zend_function_entry*)(&dst->builtin_functions[ii]), deallocate);
goto cleanup;
}
}
if(dst->refcount) deallocate(dst->refcount);
#endif
- if(dst->builtin_functions) deallocate(dst->builtin_functions);
+ if(dst->builtin_functions) deallocate((zend_function_entry*)dst->builtin_functions);
if(dst->function_table.arBuckets) my_destroy_hashtable(&dst->function_table, (ht_free_fun_t) my_free_function, deallocate);
if(dst->default_properties.arBuckets) my_destroy_hashtable(&dst->default_properties, (ht_free_fun_t) my_free_zval_ptr, deallocate);
assert(src != NULL);
if (!dst) {
+#ifdef ZEND_ENGINE_2_3
+ CHECK(dst = (zval*) allocate(sizeof(zval_gc_info)));
+
+ if(allocate == apc_php_malloc) {
+ GC_ZVAL_INIT(dst);
+ }
+#else
CHECK(dst = (zval*) allocate(sizeof(zval)));
+#endif
local_dst_alloc = 1;
}
{
assert(src != NULL);
- deallocate(src->fname);
+ deallocate((char*)src->fname);
#ifdef ZEND_ENGINE_2
if (src->arg_info) {
- my_free_arg_info_array(src->arg_info, src->num_args, deallocate);
+ my_free_arg_info_array((zend_arg_info*)src->arg_info, src->num_args, deallocate);
}
#else
if (src->func_arg_types) {
{
assert(src != NULL);
- deallocate(src->name);
- deallocate(src->class_name);
+ deallocate((char*)src->name);
+ deallocate((char*)src->class_name);
}
/* }}} */
#endif
if (src->builtin_functions) {
for (i = 0; src->builtin_functions[i].fname != NULL; i++) {
- my_destroy_function_entry(&src->builtin_functions[i], deallocate);
+ my_destroy_function_entry((zend_function_entry*)(&src->builtin_functions[i]), deallocate);
}
- deallocate(src->builtin_functions);
+ deallocate((zend_function_entry*)src->builtin_functions);
}
}
/* }}} */