-
Notifications
You must be signed in to change notification settings - Fork 9
/
php_helpers.c
47 lines (39 loc) · 2.1 KB
/
php_helpers.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
+----------------------------------------------------------------------+
| Better Function Replacer |
| based on APD Profiler & Debugger |
+----------------------------------------------------------------------+
| Copyright (c) 2001-2003 Community Connect Inc. |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.php.net/license/2_02.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Lukas Rist <[email protected]> |
| Daniel Cowgill <[email protected]> |
| George Schlossnagle <[email protected]> |
| Sterling Hughes <[email protected]> |
| Nikita Tokarchuk <[email protected]> |
+----------------------------------------------------------------------+
*/
#include "php_helpers.h"
zend_function *duplicate_function(zend_function *func)
{
zend_function *new_function;
if (func->type != ZEND_INTERNAL_FUNCTION)
{
new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(new_function, func, sizeof(zend_op_array));
function_add_ref(new_function);
return new_function;
}
new_function = zend_arena_alloc(&CG(arena), sizeof(zend_internal_function));
memcpy(new_function, func, sizeof(zend_internal_function));
new_function->common.fn_flags |= ZEND_ACC_ARENA_ALLOCATED;
function_add_ref(new_function);
return new_function;
}