PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - Zend - zend.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 482 537 89.8 %
Date: 2015-08-29 Functions: 42 44 95.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 2.00 of the Zend license,     |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.zend.com/license/2_00.txt.                                |
      11             :    | If you did not receive a copy of the Zend license and are unable to  |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@zend.com so we can mail you a copy immediately.              |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Andi Gutmans <andi@zend.com>                                |
      16             :    |          Zeev Suraski <zeev@zend.com>                                |
      17             :    +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : /* $Id$ */
      21             : 
      22             : #include "zend.h"
      23             : #include "zend_extensions.h"
      24             : #include "zend_modules.h"
      25             : #include "zend_constants.h"
      26             : #include "zend_list.h"
      27             : #include "zend_API.h"
      28             : #include "zend_exceptions.h"
      29             : #include "zend_builtin_functions.h"
      30             : #include "zend_ini.h"
      31             : #include "zend_vm.h"
      32             : #include "zend_dtrace.h"
      33             : #include "zend_virtual_cwd.h"
      34             : 
      35             : #ifdef ZTS
      36             : # define GLOBAL_FUNCTION_TABLE          global_function_table
      37             : # define GLOBAL_CLASS_TABLE                     global_class_table
      38             : # define GLOBAL_CONSTANTS_TABLE         global_constants_table
      39             : # define GLOBAL_AUTO_GLOBALS_TABLE      global_auto_globals_table
      40             : #else
      41             : # define GLOBAL_FUNCTION_TABLE          CG(function_table)
      42             : # define GLOBAL_CLASS_TABLE                     CG(class_table)
      43             : # define GLOBAL_AUTO_GLOBALS_TABLE      CG(auto_globals)
      44             : # define GLOBAL_CONSTANTS_TABLE         EG(zend_constants)
      45             : #endif
      46             : 
      47             : /* true multithread-shared globals */
      48             : ZEND_API zend_class_entry *zend_standard_class_def = NULL;
      49             : ZEND_API size_t (*zend_printf)(const char *format, ...);
      50             : ZEND_API zend_write_func_t zend_write;
      51             : ZEND_API FILE *(*zend_fopen)(const char *filename, zend_string **opened_path);
      52             : ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
      53             : ZEND_API void (*zend_block_interruptions)(void);
      54             : ZEND_API void (*zend_unblock_interruptions)(void);
      55             : ZEND_API void (*zend_ticks_function)(int ticks);
      56             : ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
      57             : size_t (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
      58             : zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap);
      59             : ZEND_API char *(*zend_getenv)(char *name, size_t name_len);
      60             : ZEND_API zend_string *(*zend_resolve_path)(const char *filename, int filename_len);
      61             : 
      62             : void (*zend_on_timeout)(int seconds);
      63             : 
      64             : static void (*zend_message_dispatcher_p)(zend_long message, const void *data);
      65             : static zval *(*zend_get_configuration_directive_p)(zend_string *name);
      66             : 
      67       23813 : static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
      68             : {
      69       23813 :         if (!new_value) {
      70         193 :                 EG(error_reporting) = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED;
      71             :         } else {
      72       23620 :                 EG(error_reporting) = atoi(ZSTR_VAL(new_value));
      73             :         }
      74       23813 :         return SUCCESS;
      75             : }
      76             : /* }}} */
      77             : 
      78       21313 : static ZEND_INI_MH(OnUpdateGCEnabled) /* {{{ */
      79             : {
      80       21313 :         OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
      81             : 
      82       21313 :         if (GC_G(gc_enabled)) {
      83       21305 :                 gc_init();
      84             :         }
      85             : 
      86       21313 :         return SUCCESS;
      87             : }
      88             : /* }}} */
      89             : 
      90       21291 : static ZEND_INI_MH(OnUpdateScriptEncoding) /* {{{ */
      91             : {
      92       21291 :         if (!CG(multibyte)) {
      93       21248 :                 return FAILURE;
      94             :         }
      95          43 :         if (!zend_multibyte_get_functions()) {
      96          43 :                 return SUCCESS;
      97             :         }
      98           0 :         return zend_multibyte_set_script_encoding_by_string(new_value ? ZSTR_VAL(new_value) : NULL, new_value ? ZSTR_LEN(new_value) : 0);
      99             : }
     100             : /* }}} */
     101             : 
     102       21304 : static ZEND_INI_MH(OnUpdateAssertions) /* {{{ */
     103             : {
     104             :         zend_long *p, val;
     105             : #ifndef ZTS
     106       21304 :         char *base = (char *) mh_arg2;
     107             : #else
     108             :         char *base;
     109             : 
     110             :         base = (char *) ts_resource(*((int *) mh_arg2));
     111             : #endif
     112             : 
     113       21304 :         p = (zend_long *) (base+(size_t) mh_arg1);
     114             : 
     115       21304 :         val = zend_atol(ZSTR_VAL(new_value), (int)ZSTR_LEN(new_value));
     116             : 
     117       21326 :         if (stage != ZEND_INI_STAGE_STARTUP &&
     118             :             stage != ZEND_INI_STAGE_SHUTDOWN &&
     119          13 :             *p != val &&
     120           9 :             (*p < 0 || val < 0)) {
     121           3 :                 zend_error(E_WARNING, "zend.assertions may be completely enabled or disabled only in php.ini");
     122           3 :                 return FAILURE;
     123             :         }
     124             : 
     125       21301 :         *p = val;
     126       21301 :         return SUCCESS;
     127             : }
     128             : /* }}} */
     129             : 
     130             : ZEND_INI_BEGIN()
     131             :         ZEND_INI_ENTRY("error_reporting",                             NULL,           ZEND_INI_ALL,           OnUpdateErrorReporting)
     132             :         STD_ZEND_INI_BOOLEAN("zend.assertions",                               "1",    ZEND_INI_ALL,       OnUpdateAssertions,           assertions,   zend_executor_globals,  executor_globals)
     133             :         STD_ZEND_INI_BOOLEAN("zend.enable_gc",                                "1",  ZEND_INI_ALL,           OnUpdateGCEnabled,      gc_enabled,     zend_gc_globals,        gc_globals)
     134             :         STD_ZEND_INI_BOOLEAN("zend.multibyte", "0", ZEND_INI_PERDIR, OnUpdateBool, multibyte,      zend_compiler_globals, compiler_globals)
     135             :         ZEND_INI_ENTRY("zend.script_encoding",                        NULL,           ZEND_INI_ALL,           OnUpdateScriptEncoding)
     136             :         STD_ZEND_INI_BOOLEAN("zend.detect_unicode",                   "1",  ZEND_INI_ALL,           OnUpdateBool, detect_unicode, zend_compiler_globals, compiler_globals)
     137             : #ifdef ZEND_SIGNALS
     138             :         STD_ZEND_INI_BOOLEAN("zend.signal_check", "0", ZEND_INI_SYSTEM, OnUpdateBool, check, zend_signal_globals_t, zend_signal_globals)
     139             : #endif
     140             : ZEND_INI_END()
     141             : 
     142             : 
     143             : #ifdef ZTS
     144             : ZEND_API int compiler_globals_id;
     145             : ZEND_API int executor_globals_id;
     146             : static HashTable *global_function_table = NULL;
     147             : static HashTable *global_class_table = NULL;
     148             : static HashTable *global_constants_table = NULL;
     149             : static HashTable *global_auto_globals_table = NULL;
     150             : static HashTable *global_persistent_list = NULL;
     151             : ZEND_TSRMLS_CACHE_DEFINE();
     152             : #endif
     153             : 
     154             : ZEND_API zend_utility_values zend_uv;
     155             : 
     156             : /* version information */
     157             : static char *zend_version_info;
     158             : static uint zend_version_info_length;
     159             : #define ZEND_CORE_VERSION_INFO  "Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2015 Zend Technologies\n"
     160             : #define PRINT_ZVAL_INDENT 4
     161             : 
     162        1375 : static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent, zend_bool is_object) /* {{{ */
     163             : {
     164             :         zval *tmp;
     165             :         zend_string *string_key;
     166             :         zend_ulong num_key;
     167             :         int i;
     168             : 
     169        6415 :         for (i = 0; i < indent; i++) {
     170        5040 :                 ZEND_PUTS_EX(" ");
     171             :         }
     172        1375 :         ZEND_PUTS_EX("(\n");
     173        1375 :         indent += PRINT_ZVAL_INDENT;
     174       14379 :         ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, string_key, tmp) {
     175        6382 :                 if (Z_TYPE_P(tmp) == IS_INDIRECT) {
     176         394 :                         tmp = Z_INDIRECT_P(tmp);
     177         394 :                         if (Z_TYPE_P(tmp) == IS_UNDEF) {
     178           0 :                                 continue;
     179             :                         }
     180             :                 }
     181       46270 :                 for (i = 0; i < indent; i++) {
     182       39888 :                         ZEND_PUTS_EX(" ");
     183             :                 }
     184        6382 :                 ZEND_PUTS_EX("[");
     185        6382 :                 if (string_key) {
     186        4409 :                         if (is_object) {
     187             :                                 const char *prop_name, *class_name;
     188             :                                 size_t prop_len;
     189         776 :                                 int mangled = zend_unmangle_property_name_ex(string_key, &class_name, &prop_name, &prop_len);
     190             : 
     191         776 :                                 ZEND_WRITE_EX(prop_name, prop_len);
     192         776 :                                 if (class_name && mangled == SUCCESS) {
     193         215 :                                         if (class_name[0]=='*') {
     194         105 :                                                 ZEND_PUTS_EX(":protected");
     195             :                                         } else {
     196         110 :                                                 ZEND_PUTS_EX(":");
     197         110 :                                                 ZEND_PUTS_EX(class_name);
     198         110 :                                                 ZEND_PUTS_EX(":private");
     199             :                                         }
     200             :                                 }
     201             :                         } else {
     202        3633 :                                 ZEND_WRITE_EX(ZSTR_VAL(string_key), ZSTR_LEN(string_key));
     203             :                         }
     204             :                 } else {
     205             :                         char key[25];
     206        1973 :                         snprintf(key, sizeof(key), ZEND_LONG_FMT, num_key);
     207        1973 :                         ZEND_PUTS_EX(key);
     208             :                 }
     209        6382 :                 ZEND_PUTS_EX("] => ");
     210        6382 :                 zend_print_zval_r_ex(write_func, tmp, indent+PRINT_ZVAL_INDENT);
     211        6382 :                 ZEND_PUTS_EX("\n");
     212             :         } ZEND_HASH_FOREACH_END();
     213        1375 :         indent -= PRINT_ZVAL_INDENT;
     214        6415 :         for (i = 0; i < indent; i++) {
     215        5040 :                 ZEND_PUTS_EX(" ");
     216             :         }
     217        1375 :         ZEND_PUTS_EX(")\n");
     218        1375 : }
     219             : /* }}} */
     220             : 
     221          19 : static void print_flat_hash(HashTable *ht) /* {{{ */
     222             : {
     223             :         zval *tmp;
     224             :         zend_string *string_key;
     225             :         zend_ulong num_key;
     226          19 :         int i = 0;
     227             : 
     228         406 :         ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, string_key, tmp) {
     229         129 :                 if (i++ > 0) {
     230         120 :                         ZEND_PUTS(",");
     231             :                 }
     232         129 :                 ZEND_PUTS("[");
     233         129 :                 if (string_key) {
     234         125 :                         ZEND_WRITE(ZSTR_VAL(string_key), ZSTR_LEN(string_key));
     235             :                 } else {
     236           4 :                         zend_printf(ZEND_ULONG_FMT, num_key);
     237             :                 }
     238         129 :                 ZEND_PUTS("] => ");
     239         129 :                 zend_print_flat_zval_r(tmp);
     240             :         } ZEND_HASH_FOREACH_END();
     241          19 : }
     242             : /* }}} */
     243             : 
     244     1427580 : ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy) /* {{{ */
     245             : {
     246     1427580 :         if (Z_TYPE_P(expr) == IS_STRING) {
     247           1 :                 return 0;
     248             :         } else {
     249     1427579 :                 ZVAL_STR(expr_copy, _zval_get_string_func(expr));
     250     1427579 :                 return 1;
     251             :         }
     252             : }
     253             : /* }}} */
     254             : 
     255        1082 : ZEND_API size_t zend_print_zval(zval *expr, int indent) /* {{{ */
     256             : {
     257        1082 :         return zend_print_zval_ex(zend_write, expr, indent);
     258             : }
     259             : /* }}} */
     260             : 
     261        7337 : ZEND_API size_t zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent) /* {{{ */
     262             : {
     263        7337 :         zend_string *str = zval_get_string(expr);
     264        7337 :         size_t len = ZSTR_LEN(str);
     265             : 
     266        7337 :         if (len != 0) {
     267        7010 :                 write_func(ZSTR_VAL(str), len);
     268             :         }
     269             : 
     270             :         zend_string_release(str);
     271        7337 :         return len;
     272             : }
     273             : /* }}} */
     274             : 
     275         182 : ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
     276             : {
     277         182 :         switch (Z_TYPE_P(expr)) {
     278             :                 case IS_ARRAY:
     279          17 :                         ZEND_PUTS("Array (");
     280          51 :                         if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr)) &&
     281          34 :                             ++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) {
     282           0 :                                 ZEND_PUTS(" *RECURSION*");
     283           0 :                                 Z_ARRVAL_P(expr)->u.v.nApplyCount--;
     284           0 :                                 return;
     285             :                         }
     286          17 :                         print_flat_hash(Z_ARRVAL_P(expr));
     287          17 :                         ZEND_PUTS(")");
     288          17 :                         if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) {
     289          17 :                                 Z_ARRVAL_P(expr)->u.v.nApplyCount--;
     290             :                         }
     291          17 :                         break;
     292             :                 case IS_OBJECT:
     293             :                 {
     294           2 :                         HashTable *properties = NULL;
     295           2 :                         zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr));
     296           2 :                         zend_printf("%s Object (", ZSTR_VAL(class_name));
     297             :                         zend_string_release(class_name);
     298             : 
     299           2 :                         if (Z_OBJ_APPLY_COUNT_P(expr) > 0) {
     300           0 :                                 ZEND_PUTS(" *RECURSION*");
     301           0 :                                 return;
     302             :                         }
     303             : 
     304           2 :                         if (Z_OBJ_HANDLER_P(expr, get_properties)) {
     305           2 :                                 properties = Z_OBJPROP_P(expr);
     306             :                         }
     307           2 :                         if (properties) {
     308           2 :                                 Z_OBJ_INC_APPLY_COUNT_P(expr);
     309           2 :                                 print_flat_hash(properties);
     310           2 :                                 Z_OBJ_DEC_APPLY_COUNT_P(expr);
     311             :                         }
     312           2 :                         ZEND_PUTS(")");
     313           2 :                         break;
     314             :                 }
     315             :                 default:
     316         163 :                         zend_print_variable(expr);
     317             :                         break;
     318             :         }
     319             : }
     320             : /* }}} */
     321             : 
     322        1260 : ZEND_API void zend_print_zval_r(zval *expr, int indent) /* {{{ */
     323             : {
     324        1260 :         zend_print_zval_r_ex(zend_write, expr, indent);
     325        1260 : }
     326             : /* }}} */
     327             : 
     328        7643 : ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent) /* {{{ */
     329             : {
     330        7643 :         ZVAL_DEREF(expr);
     331        7643 :         switch (Z_TYPE_P(expr)) {
     332             :                 case IS_ARRAY:
     333        1075 :                         ZEND_PUTS_EX("Array\n");
     334        3225 :                         if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr)) &&
     335        2150 :                             ++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) {
     336           0 :                                 ZEND_PUTS_EX(" *RECURSION*");
     337           0 :                                 Z_ARRVAL_P(expr)->u.v.nApplyCount--;
     338           0 :                                 return;
     339             :                         }
     340        1075 :                         print_hash(write_func, Z_ARRVAL_P(expr), indent, 0);
     341        1075 :                         if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) {
     342        1075 :                                 Z_ARRVAL_P(expr)->u.v.nApplyCount--;
     343             :                         }
     344        1075 :                         break;
     345             :                 case IS_OBJECT:
     346             :                         {
     347             :                                 HashTable *properties;
     348             :                                 int is_temp;
     349             : 
     350         313 :                                 zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr));
     351         313 :                                 ZEND_PUTS_EX(ZSTR_VAL(class_name));
     352             :                                 zend_string_release(class_name);
     353             : 
     354         313 :                                 ZEND_PUTS_EX(" Object\n");
     355         313 :                                 if (Z_OBJ_APPLY_COUNT_P(expr) > 0) {
     356          13 :                                         ZEND_PUTS_EX(" *RECURSION*");
     357          13 :                                         return;
     358             :                                 }
     359         300 :                                 if ((properties = Z_OBJDEBUG_P(expr, is_temp)) == NULL) {
     360           0 :                                         break;
     361             :                                 }
     362             : 
     363         300 :                                 Z_OBJ_INC_APPLY_COUNT_P(expr);
     364         300 :                                 print_hash(write_func, properties, indent, 1);
     365         300 :                                 Z_OBJ_DEC_APPLY_COUNT_P(expr);
     366             : 
     367         300 :                                 if (is_temp) {
     368          47 :                                         zend_hash_destroy(properties);
     369          47 :                                         FREE_HASHTABLE(properties);
     370             :                                 }
     371         300 :                                 break;
     372             :                         }
     373             :                 default:
     374        6255 :                         zend_print_zval_ex(write_func, expr, indent);
     375             :                         break;
     376             :         }
     377             : }
     378             : /* }}} */
     379             : 
     380           0 : static FILE *zend_fopen_wrapper(const char *filename, zend_string **opened_path) /* {{{ */
     381             : {
     382           0 :         if (opened_path) {
     383           0 :                 *opened_path = zend_string_init(filename, strlen(filename), 0);
     384             :         }
     385           0 :         return fopen(filename, "rb");
     386             : }
     387             : /* }}} */
     388             : 
     389             : #ifdef ZTS
     390             : static zend_bool short_tags_default      = 1;
     391             : static uint32_t compiler_options_default = ZEND_COMPILE_DEFAULT;
     392             : #else
     393             : # define short_tags_default                     1
     394             : # define compiler_options_default       ZEND_COMPILE_DEFAULT
     395             : #endif
     396             : 
     397       21291 : static void zend_set_default_compile_time_values(void) /* {{{ */
     398             : {
     399             :         /* default compile-time values */
     400       21291 :         CG(short_tags) = short_tags_default;
     401       21291 :         CG(compiler_options) = compiler_options_default;
     402       21291 : }
     403             : /* }}} */
     404             : 
     405             : #ifdef ZEND_WIN32
     406             : static void zend_get_windows_version_info(OSVERSIONINFOEX *osvi) /* {{{ */
     407             : {
     408             :         ZeroMemory(osvi, sizeof(OSVERSIONINFOEX));
     409             :         osvi->dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
     410             :         if(!GetVersionEx((OSVERSIONINFO *) osvi)) {
     411             :                 ZEND_ASSERT(0); /* Should not happen as sizeof is used. */
     412             :         }
     413             : }
     414             : /* }}} */
     415             : #endif
     416             : 
     417       21291 : static void zend_init_exception_op(void) /* {{{ */
     418             : {
     419       21291 :         memset(EG(exception_op), 0, sizeof(EG(exception_op)));
     420       21291 :         EG(exception_op)[0].opcode = ZEND_HANDLE_EXCEPTION;
     421       21291 :         EG(exception_op)[0].op1_type = IS_UNUSED;
     422       21291 :         EG(exception_op)[0].op2_type = IS_UNUSED;
     423       21291 :         EG(exception_op)[0].result_type = IS_UNUSED;
     424       21291 :         ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op));
     425       21291 :         EG(exception_op)[1].opcode = ZEND_HANDLE_EXCEPTION;
     426       21291 :         EG(exception_op)[1].op1_type = IS_UNUSED;
     427       21291 :         EG(exception_op)[1].op2_type = IS_UNUSED;
     428       21291 :         EG(exception_op)[1].result_type = IS_UNUSED;
     429       21291 :         ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+1);
     430       21291 :         EG(exception_op)[2].opcode = ZEND_HANDLE_EXCEPTION;
     431       21291 :         EG(exception_op)[2].op1_type = IS_UNUSED;
     432       21291 :         EG(exception_op)[2].op2_type = IS_UNUSED;
     433       21291 :         EG(exception_op)[2].result_type = IS_UNUSED;
     434       21291 :         ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+2);
     435       21291 : }
     436             : /* }}} */
     437             : 
     438       21291 : static void zend_init_call_trampoline_op(void) /* {{{ */
     439             : {
     440       21291 :         memset(&EG(call_trampoline_op), 0, sizeof(EG(call_trampoline_op)));
     441       21291 :         EG(call_trampoline_op).opcode = ZEND_CALL_TRAMPOLINE;
     442       21291 :         EG(call_trampoline_op).op1_type = IS_UNUSED;
     443       21291 :         EG(call_trampoline_op).op2_type = IS_UNUSED;
     444       21291 :         EG(call_trampoline_op).result_type = IS_UNUSED;
     445       21291 :         ZEND_VM_SET_OPCODE_HANDLER(&EG(call_trampoline_op));
     446       21291 : }
     447             : /* }}} */
     448             : 
     449             : #ifdef ZTS
     450             : static void function_copy_ctor(zval *zv)
     451             : {
     452             :         zend_function *old_func = Z_FUNC_P(zv);
     453             :         Z_FUNC_P(zv) = pemalloc(sizeof(zend_internal_function), 1);
     454             :         memcpy(Z_FUNC_P(zv), old_func, sizeof(zend_internal_function));
     455             :         function_add_ref(Z_FUNC_P(zv));
     456             : }
     457             : 
     458             : static void auto_global_copy_ctor(zval *zv)
     459             : {
     460             :         zend_auto_global *old_ag = (zend_auto_global *) Z_PTR_P(zv);
     461             :         zend_auto_global *new_ag = pemalloc(sizeof(zend_auto_global), 1);
     462             : 
     463             :         new_ag->name = zend_string_copy(old_ag->name);
     464             :         new_ag->auto_global_callback = old_ag->auto_global_callback;
     465             :         new_ag->jit = old_ag->jit;
     466             : 
     467             :         Z_PTR_P(zv) = new_ag;
     468             : }
     469             : 
     470             : static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{{ */
     471             : {
     472             :         compiler_globals->compiled_filename = NULL;
     473             : 
     474             :         compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
     475             :         zend_hash_init_ex(compiler_globals->function_table, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0);
     476             :         zend_hash_copy(compiler_globals->function_table, global_function_table, function_copy_ctor);
     477             : 
     478             :         compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
     479             :         zend_hash_init_ex(compiler_globals->class_table, 64, NULL, ZEND_CLASS_DTOR, 1, 0);
     480             :         zend_hash_copy(compiler_globals->class_table, global_class_table, zend_class_add_ref);
     481             : 
     482             :         zend_set_default_compile_time_values();
     483             : 
     484             :         compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable));
     485             :         zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, NULL, 1, 0);
     486             :         zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, auto_global_copy_ctor);
     487             : 
     488             :         compiler_globals->last_static_member = zend_hash_num_elements(compiler_globals->class_table);
     489             :         if (compiler_globals->last_static_member) {
     490             :                 compiler_globals->static_members_table = calloc(compiler_globals->last_static_member, sizeof(zval*));
     491             :         } else {
     492             :                 compiler_globals->static_members_table = NULL;
     493             :         }
     494             :         compiler_globals->script_encoding_list = NULL;
     495             : 
     496             :         zend_interned_empty_string_init(&compiler_globals->empty_string);
     497             : 
     498             :         memset(compiler_globals->one_char_string, 0, sizeof(compiler_globals->one_char_string));
     499             : }
     500             : /* }}} */
     501             : 
     502             : static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) /* {{{ */
     503             : {
     504             :         if (compiler_globals->function_table != GLOBAL_FUNCTION_TABLE) {
     505             :                 zend_hash_destroy(compiler_globals->function_table);
     506             :                 free(compiler_globals->function_table);
     507             :         }
     508             :         if (compiler_globals->class_table != GLOBAL_CLASS_TABLE) {
     509             :                 zend_hash_destroy(compiler_globals->class_table);
     510             :                 free(compiler_globals->class_table);
     511             :         }
     512             :         if (compiler_globals->auto_globals != GLOBAL_AUTO_GLOBALS_TABLE) {
     513             :                 zend_hash_destroy(compiler_globals->auto_globals);
     514             :                 free(compiler_globals->auto_globals);
     515             :         }
     516             :         if (compiler_globals->static_members_table) {
     517             :                 free(compiler_globals->static_members_table);
     518             :         }
     519             :         if (compiler_globals->script_encoding_list) {
     520             :                 pefree((char*)compiler_globals->script_encoding_list, 1);
     521             :         }
     522             :         compiler_globals->last_static_member = 0;
     523             : 
     524             :         zend_interned_empty_string_free(&compiler_globals->empty_string);
     525             : }
     526             : /* }}} */
     527             : 
     528             : static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{{ */
     529             : {
     530             :         ZEND_TSRMLS_CACHE_UPDATE();
     531             : 
     532             :         zend_startup_constants();
     533             :         zend_copy_constants(EG(zend_constants), GLOBAL_CONSTANTS_TABLE);
     534             :         zend_init_rsrc_plist();
     535             :         zend_init_exception_op();
     536             :         zend_init_call_trampoline_op();
     537             :         memset(&executor_globals->trampoline, 0, sizeof(zend_op_array));
     538             :         executor_globals->lambda_count = 0;
     539             :         ZVAL_UNDEF(&executor_globals->user_error_handler);
     540             :         ZVAL_UNDEF(&executor_globals->user_exception_handler);
     541             :         executor_globals->in_autoload = NULL;
     542             :         executor_globals->current_execute_data = NULL;
     543             :         executor_globals->current_module = NULL;
     544             :         executor_globals->exit_status = 0;
     545             : #if XPFPA_HAVE_CW
     546             :         executor_globals->saved_fpu_cw = 0;
     547             : #endif
     548             :         executor_globals->saved_fpu_cw_ptr = NULL;
     549             :         executor_globals->active = 0;
     550             :         executor_globals->bailout = NULL;
     551             :         executor_globals->error_handling  = EH_NORMAL;
     552             :         executor_globals->exception_class = NULL;
     553             :         executor_globals->exception = NULL;
     554             :         executor_globals->objects_store.object_buckets = NULL;
     555             : #ifdef ZEND_WIN32
     556             :         zend_get_windows_version_info(&executor_globals->windows_version_info);
     557             : #endif
     558             : }
     559             : /* }}} */
     560             : 
     561             : static void executor_globals_dtor(zend_executor_globals *executor_globals) /* {{{ */
     562             : {
     563             :         zend_ini_dtor(executor_globals->ini_directives);
     564             : 
     565             :         if (&executor_globals->persistent_list != global_persistent_list) {
     566             :                 zend_destroy_rsrc_list(&executor_globals->persistent_list);
     567             :         }
     568             :         if (executor_globals->zend_constants != GLOBAL_CONSTANTS_TABLE) {
     569             :                 zend_hash_destroy(executor_globals->zend_constants);
     570             :                 free(executor_globals->zend_constants);
     571             :         }
     572             : }
     573             : /* }}} */
     574             : 
     575             : static void zend_new_thread_end_handler(THREAD_T thread_id) /* {{{ */
     576             : {
     577             :         if (zend_copy_ini_directives() == SUCCESS) {
     578             :                 zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP);
     579             :         }
     580             : }
     581             : /* }}} */
     582             : #endif
     583             : 
     584             : #if defined(__FreeBSD__) || defined(__DragonFly__)
     585             : /* FreeBSD and DragonFly floating point precision fix */
     586             : #include <floatingpoint.h>
     587             : #endif
     588             : 
     589       21291 : static void ini_scanner_globals_ctor(zend_ini_scanner_globals *scanner_globals_p) /* {{{ */
     590             : {
     591       21291 :         memset(scanner_globals_p, 0, sizeof(*scanner_globals_p));
     592       21291 : }
     593             : /* }}} */
     594             : 
     595       21291 : static void php_scanner_globals_ctor(zend_php_scanner_globals *scanner_globals_p) /* {{{ */
     596             : {
     597       21291 :         memset(scanner_globals_p, 0, sizeof(*scanner_globals_p));
     598       21291 : }
     599             : /* }}} */
     600             : 
     601             : void zend_init_opcodes_handlers(void);
     602             : 
     603     1450473 : static void module_destructor_zval(zval *zv) /* {{{ */
     604             : {
     605     1450473 :         zend_module_entry *module = (zend_module_entry*)Z_PTR_P(zv);
     606             : 
     607     1450473 :         module_destructor(module);
     608     1450473 :         free(module);
     609     1450473 : }
     610             : /* }}} */
     611             : 
     612      191943 : static void auto_global_dtor(zval *zv) /* {{{ */
     613             : {
     614      191943 :         free(Z_PTR_P(zv));
     615      191943 : }
     616             : /* }}} */
     617             : 
     618         173 : static zend_bool php_auto_globals_create_globals(zend_string *name) /* {{{ */
     619             : {
     620             :         zval globals;
     621             : 
     622         173 :         ZVAL_ARR(&globals, &EG(symbol_table));
     623         173 :         Z_TYPE_INFO_P(&globals) = IS_ARRAY | (IS_TYPE_SYMBOLTABLE << Z_TYPE_FLAGS_SHIFT);
     624         173 :         ZVAL_NEW_REF(&globals, &globals);
     625         173 :         zend_hash_update(&EG(symbol_table), name, &globals);
     626         173 :         return 0;
     627             : }
     628             : /* }}} */
     629             : 
     630       21291 : int zend_startup(zend_utility_functions *utility_functions, char **extensions) /* {{{ */
     631             : {
     632             : #ifdef ZTS
     633             :         zend_compiler_globals *compiler_globals;
     634             :         zend_executor_globals *executor_globals;
     635             :         extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
     636             :         extern ZEND_API ts_rsrc_id language_scanner_globals_id;
     637             :         ZEND_TSRMLS_CACHE_UPDATE();
     638             : #else
     639             :         extern zend_ini_scanner_globals ini_scanner_globals;
     640             :         extern zend_php_scanner_globals language_scanner_globals;
     641             : #endif
     642             : 
     643       21291 :         start_memory_manager();
     644             : 
     645       21291 :         virtual_cwd_startup(); /* Could use shutdown to free the main cwd but it would just slow it down for CGI */
     646             : 
     647             : #if defined(__FreeBSD__) || defined(__DragonFly__)
     648             :         /* FreeBSD and DragonFly floating point precision fix */
     649             :         fpsetmask(0);
     650             : #endif
     651             : 
     652       21291 :         zend_startup_strtod();
     653       21291 :         zend_startup_extensions_mechanism();
     654             : 
     655             :         /* Set up utility functions and values */
     656       21291 :         zend_error_cb = utility_functions->error_function;
     657       21291 :         zend_printf = utility_functions->printf_function;
     658       21291 :         zend_write = (zend_write_func_t) utility_functions->write_function;
     659       21291 :         zend_fopen = utility_functions->fopen_function;
     660       21291 :         if (!zend_fopen) {
     661           0 :                 zend_fopen = zend_fopen_wrapper;
     662             :         }
     663       21291 :         zend_stream_open_function = utility_functions->stream_open_function;
     664       21291 :         zend_message_dispatcher_p = utility_functions->message_handler;
     665             : #ifndef ZEND_SIGNALS
     666       21291 :         zend_block_interruptions = utility_functions->block_interruptions;
     667       21291 :         zend_unblock_interruptions = utility_functions->unblock_interruptions;
     668             : #endif
     669       21291 :         zend_get_configuration_directive_p = utility_functions->get_configuration_directive;
     670       21291 :         zend_ticks_function = utility_functions->ticks_function;
     671       21291 :         zend_on_timeout = utility_functions->on_timeout;
     672       21291 :         zend_vspprintf = utility_functions->vspprintf_function;
     673       21291 :         zend_vstrpprintf = utility_functions->vstrpprintf_function;
     674       21291 :         zend_getenv = utility_functions->getenv_function;
     675       21291 :         zend_resolve_path = utility_functions->resolve_path_function;
     676             : 
     677             : #if HAVE_DTRACE
     678             : /* build with dtrace support */
     679             :         zend_compile_file = dtrace_compile_file;
     680             :         zend_execute_ex = dtrace_execute_ex;
     681             :         zend_execute_internal = dtrace_execute_internal;
     682             : #else
     683       21291 :         zend_compile_file = compile_file;
     684       21291 :         zend_execute_ex = execute_ex;
     685       21291 :         zend_execute_internal = NULL;
     686             : #endif /* HAVE_SYS_SDT_H */
     687       21291 :         zend_compile_string = compile_string;
     688       21291 :         zend_throw_exception_hook = NULL;
     689             : 
     690             :         /* Set up the default garbage collection implementation. */
     691       21291 :         gc_collect_cycles = zend_gc_collect_cycles;
     692             : 
     693       21291 :         zend_init_opcodes_handlers();
     694             : 
     695             :         /* set up version */
     696       21291 :         zend_version_info = strdup(ZEND_CORE_VERSION_INFO);
     697       21291 :         zend_version_info_length = sizeof(ZEND_CORE_VERSION_INFO) - 1;
     698             : 
     699       21291 :         GLOBAL_FUNCTION_TABLE = (HashTable *) malloc(sizeof(HashTable));
     700       21291 :         GLOBAL_CLASS_TABLE = (HashTable *) malloc(sizeof(HashTable));
     701       21291 :         GLOBAL_AUTO_GLOBALS_TABLE = (HashTable *) malloc(sizeof(HashTable));
     702       21291 :         GLOBAL_CONSTANTS_TABLE = (HashTable *) malloc(sizeof(HashTable));
     703             : 
     704       21291 :         zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0);
     705       21291 :         zend_hash_init_ex(GLOBAL_CLASS_TABLE, 64, NULL, ZEND_CLASS_DTOR, 1, 0);
     706       21291 :         zend_hash_init_ex(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, auto_global_dtor, 1, 0);
     707       21291 :         zend_hash_init_ex(GLOBAL_CONSTANTS_TABLE, 128, NULL, ZEND_CONSTANT_DTOR, 1, 0);
     708             : 
     709       21291 :         zend_hash_init_ex(&module_registry, 32, NULL, module_destructor_zval, 1, 0);
     710       21291 :         zend_init_rsrc_list_dtors();
     711             : 
     712             : #ifdef ZTS
     713             :         ts_allocate_id(&compiler_globals_id, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
     714             :         ts_allocate_id(&executor_globals_id, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
     715             :         ts_allocate_id(&language_scanner_globals_id, sizeof(zend_php_scanner_globals), (ts_allocate_ctor) php_scanner_globals_ctor, NULL);
     716             :         ts_allocate_id(&ini_scanner_globals_id, sizeof(zend_ini_scanner_globals), (ts_allocate_ctor) ini_scanner_globals_ctor, NULL);
     717             :         compiler_globals = ts_resource(compiler_globals_id);
     718             :         executor_globals = ts_resource(executor_globals_id);
     719             : 
     720             :         compiler_globals_dtor(compiler_globals);
     721             :         compiler_globals->in_compilation = 0;
     722             :         compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
     723             :         compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
     724             : 
     725             :         *compiler_globals->function_table = *GLOBAL_FUNCTION_TABLE;
     726             :         *compiler_globals->class_table = *GLOBAL_CLASS_TABLE;
     727             :         compiler_globals->auto_globals = GLOBAL_AUTO_GLOBALS_TABLE;
     728             : 
     729             :         zend_hash_destroy(executor_globals->zend_constants);
     730             :         *executor_globals->zend_constants = *GLOBAL_CONSTANTS_TABLE;
     731             : #else
     732       21291 :         ini_scanner_globals_ctor(&ini_scanner_globals);
     733       21291 :         php_scanner_globals_ctor(&language_scanner_globals);
     734       21291 :         zend_set_default_compile_time_values();
     735             : #ifdef ZEND_WIN32
     736             :         zend_get_windows_version_info(&EG(windows_version_info));
     737             : #endif
     738             : #endif
     739       21291 :         EG(error_reporting) = E_ALL & ~E_NOTICE;
     740             : 
     741       21291 :         zend_interned_strings_init();
     742       21291 :         zend_startup_builtin_functions();
     743       21291 :         zend_register_standard_constants();
     744       21291 :         zend_register_auto_global(zend_string_init("GLOBALS", sizeof("GLOBALS") - 1, 1), 1, php_auto_globals_create_globals);
     745             : 
     746             : #ifndef ZTS
     747       21291 :         zend_init_rsrc_plist();
     748       21291 :         zend_init_exception_op();
     749       21291 :         zend_init_call_trampoline_op();
     750             : #endif
     751             : 
     752       21291 :         zend_ini_startup();
     753             : 
     754             : #ifdef ZTS
     755             :         tsrm_set_new_thread_end_handler(zend_new_thread_end_handler);
     756             : #endif
     757             : 
     758             : #ifdef ZEND_SIGNALS
     759             :         zend_signal_startup();
     760             : #endif
     761             : 
     762       21291 :         return SUCCESS;
     763             : }
     764             : /* }}} */
     765             : 
     766       21291 : void zend_register_standard_ini_entries(void) /* {{{ */
     767             : {
     768       21291 :         int module_number = 0;
     769             : 
     770       21291 :         REGISTER_INI_ENTRIES();
     771       21291 : }
     772             : /* }}} */
     773             : 
     774             : /* Unlink the global (r/o) copies of the class, function and constant tables,
     775             :  * and use a fresh r/w copy for the startup thread
     776             :  */
     777       21291 : void zend_post_startup(void) /* {{{ */
     778             : {
     779             : #ifdef ZTS
     780             :         zend_encoding **script_encoding_list;
     781             : 
     782             :         zend_compiler_globals *compiler_globals = ts_resource(compiler_globals_id);
     783             :         zend_executor_globals *executor_globals = ts_resource(executor_globals_id);
     784             : 
     785             :         *GLOBAL_FUNCTION_TABLE = *compiler_globals->function_table;
     786             :         *GLOBAL_CLASS_TABLE = *compiler_globals->class_table;
     787             :         *GLOBAL_CONSTANTS_TABLE = *executor_globals->zend_constants;
     788             : 
     789             :         short_tags_default = CG(short_tags);
     790             :         compiler_options_default = CG(compiler_options);
     791             : 
     792             :         zend_destroy_rsrc_list(&EG(persistent_list));
     793             :         free(compiler_globals->function_table);
     794             :         free(compiler_globals->class_table);
     795             :         if ((script_encoding_list = (zend_encoding **)compiler_globals->script_encoding_list)) {
     796             :                 compiler_globals_ctor(compiler_globals);
     797             :                 compiler_globals->script_encoding_list = (const zend_encoding **)script_encoding_list;
     798             :         } else {
     799             :                 compiler_globals_ctor(compiler_globals);
     800             :         }
     801             :         free(EG(zend_constants));
     802             : 
     803             :         virtual_cwd_deactivate();
     804             : 
     805             :         executor_globals_ctor(executor_globals);
     806             :         global_persistent_list = &EG(persistent_list);
     807             :         zend_copy_ini_directives();
     808             : #else
     809       21291 :         virtual_cwd_deactivate();
     810             : #endif
     811       21291 : }
     812             : /* }}} */
     813             : 
     814       21327 : void zend_shutdown(void) /* {{{ */
     815             : {
     816       21327 :         zend_destroy_rsrc_list(&EG(persistent_list));
     817       21327 :         if (EG(active))
     818             :         {
     819             :                 /*
     820             :                  * The order of destruction is important here.
     821             :                  * See bugs #65463 and 66036.
     822             :                  */
     823             :                 zend_function *func;
     824             :                 zend_class_entry *ce;
     825             : 
     826           0 :                 ZEND_HASH_REVERSE_FOREACH_PTR(GLOBAL_FUNCTION_TABLE, func) {
     827           0 :                         if (func->type == ZEND_USER_FUNCTION) {
     828           0 :                                 zend_cleanup_op_array_data((zend_op_array *) func);
     829             :                         }
     830             :                 } ZEND_HASH_FOREACH_END();
     831           0 :                 ZEND_HASH_REVERSE_FOREACH_PTR(GLOBAL_CLASS_TABLE, ce) {
     832           0 :                         if (ce->type == ZEND_USER_CLASS) {
     833           0 :                                 zend_cleanup_user_class_data(ce);
     834             :                         } else {
     835           0 :                                 break;
     836             :                         }
     837             :                 } ZEND_HASH_FOREACH_END();
     838           0 :                 zend_cleanup_internal_classes();
     839           0 :                 zend_hash_reverse_apply(GLOBAL_FUNCTION_TABLE, (apply_func_t) clean_non_persistent_function_full);
     840           0 :                 zend_hash_reverse_apply(GLOBAL_CLASS_TABLE, (apply_func_t) clean_non_persistent_class_full);
     841             :         }
     842       21327 :         zend_destroy_modules();
     843             : 
     844       21327 :         virtual_cwd_deactivate();
     845       21327 :         virtual_cwd_shutdown();
     846             : 
     847       21327 :         zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
     848       21327 :         zend_hash_destroy(GLOBAL_CLASS_TABLE);
     849             : 
     850       21327 :         zend_hash_destroy(GLOBAL_AUTO_GLOBALS_TABLE);
     851       21327 :         free(GLOBAL_AUTO_GLOBALS_TABLE);
     852             : 
     853       21327 :         zend_shutdown_extensions();
     854       21327 :         free(zend_version_info);
     855             : 
     856       21327 :         free(GLOBAL_FUNCTION_TABLE);
     857       21327 :         free(GLOBAL_CLASS_TABLE);
     858             : 
     859       21327 :         zend_hash_destroy(GLOBAL_CONSTANTS_TABLE);
     860       21327 :         free(GLOBAL_CONSTANTS_TABLE);
     861       21327 :         zend_shutdown_strtod();
     862             : 
     863             : #ifdef ZTS
     864             :         GLOBAL_FUNCTION_TABLE = NULL;
     865             :         GLOBAL_CLASS_TABLE = NULL;
     866             :         GLOBAL_AUTO_GLOBALS_TABLE = NULL;
     867             :         GLOBAL_CONSTANTS_TABLE = NULL;
     868             : #endif
     869       21327 :         zend_destroy_rsrc_list_dtors();
     870             : 
     871       21327 :         zend_interned_strings_dtor();
     872       21327 : }
     873             : /* }}} */
     874             : 
     875       21291 : void zend_set_utility_values(zend_utility_values *utility_values) /* {{{ */
     876             : {
     877       21291 :         zend_uv = *utility_values;
     878       21291 :         zend_uv.import_use_extension_length = (uint)strlen(zend_uv.import_use_extension);
     879       21291 : }
     880             : /* }}} */
     881             : 
     882             : /* this should be compatible with the standard zenderror */
     883          61 : ZEND_COLD void zenderror(const char *error) /* {{{ */
     884             : {
     885          61 :         if (EG(exception)) {
     886             :                 /* An exception was thrown in the lexer, don't throw another in the parser. */
     887          14 :                 return;
     888             :         }
     889             : 
     890          47 :         zend_throw_exception(zend_ce_parse_error, error, 0);
     891             : }
     892             : /* }}} */
     893             : 
     894             : BEGIN_EXTERN_C()
     895        2298 : ZEND_API ZEND_COLD void _zend_bailout(char *filename, uint lineno) /* {{{ */
     896             : {
     897             : 
     898        2298 :         if (!EG(bailout)) {
     899           0 :                 zend_output_debug_string(1, "%s(%d) : Bailed out without a bailout address!", filename, lineno);
     900           0 :                 exit(-1);
     901             :         }
     902        2298 :         CG(unclean_shutdown) = 1;
     903        2298 :         CG(active_class_entry) = NULL;
     904        2298 :         CG(in_compilation) = 0;
     905        2298 :         EG(current_execute_data) = NULL;
     906        2298 :         LONGJMP(*EG(bailout), FAILURE);
     907             : }
     908             : /* }}} */
     909             : END_EXTERN_C()
     910             : 
     911       21122 : ZEND_API void zend_append_version_info(const zend_extension *extension) /* {{{ */
     912             : {
     913             :         char *new_info;
     914             :         uint new_info_length;
     915             : 
     916       84488 :         new_info_length = (uint)(sizeof("    with  v, , by \n")
     917       21122 :                                                 + strlen(extension->name)
     918       21122 :                                                 + strlen(extension->version)
     919       21122 :                                                 + strlen(extension->copyright)
     920       21122 :                                                 + strlen(extension->author));
     921             : 
     922       21122 :         new_info = (char *) malloc(new_info_length + 1);
     923             : 
     924       21122 :         snprintf(new_info, new_info_length, "    with %s v%s, %s, by %s\n", extension->name, extension->version, extension->copyright, extension->author);
     925             : 
     926       21122 :         zend_version_info = (char *) realloc(zend_version_info, zend_version_info_length+new_info_length + 1);
     927       21122 :         strncat(zend_version_info, new_info, new_info_length);
     928       21122 :         zend_version_info_length += new_info_length;
     929       21122 :         free(new_info);
     930       21122 : }
     931             : /* }}} */
     932             : 
     933         165 : ZEND_API char *get_zend_version(void) /* {{{ */
     934             : {
     935         165 :         return zend_version_info;
     936             : }
     937             : /* }}} */
     938             : 
     939       21248 : ZEND_API void zend_activate(void) /* {{{ */
     940             : {
     941             : #ifdef ZTS
     942             :         virtual_cwd_activate();
     943             : #endif
     944       21248 :         gc_reset();
     945       21248 :         init_compiler();
     946       21248 :         init_executor();
     947       21248 :         startup_scanner();
     948       21248 : }
     949             : /* }}} */
     950             : 
     951       21286 : void zend_call_destructors(void) /* {{{ */
     952             : {
     953       21286 :         zend_try {
     954       21286 :                 shutdown_destructors();
     955       21286 :         } zend_end_try();
     956       21286 : }
     957             : /* }}} */
     958             : 
     959       21286 : ZEND_API void zend_deactivate(void) /* {{{ */
     960             : {
     961             :         /* we're no longer executing anything */
     962       21286 :         EG(current_execute_data) = NULL;
     963             : 
     964       21286 :         zend_try {
     965       21286 :                 shutdown_scanner();
     966       21286 :         } zend_end_try();
     967             : 
     968             :         /* shutdown_executor() takes care of its own bailout handling */
     969       21286 :         shutdown_executor();
     970             : 
     971       21286 :         zend_try {
     972       21286 :                 shutdown_compiler();
     973       21286 :         } zend_end_try();
     974             : 
     975       21286 :         zend_destroy_rsrc_list(&EG(regular_list));
     976             : 
     977             : #if GC_BENCH
     978             :         fprintf(stderr, "GC Statistics\n");
     979             :         fprintf(stderr, "-------------\n");
     980             :         fprintf(stderr, "Runs:               %d\n", GC_G(gc_runs));
     981             :         fprintf(stderr, "Collected:          %d\n", GC_G(collected));
     982             :         fprintf(stderr, "Root buffer length: %d\n", GC_G(root_buf_length));
     983             :         fprintf(stderr, "Root buffer peak:   %d\n\n", GC_G(root_buf_peak));
     984             :         fprintf(stderr, "      Possible            Remove from  Marked\n");
     985             :         fprintf(stderr, "        Root    Buffered     buffer     grey\n");
     986             :         fprintf(stderr, "      --------  --------  -----------  ------\n");
     987             :         fprintf(stderr, "ZVAL  %8d  %8d  %9d  %8d\n", GC_G(zval_possible_root), GC_G(zval_buffered), GC_G(zval_remove_from_buffer), GC_G(zval_marked_grey));
     988             :         fprintf(stderr, "ZOBJ  %8d  %8d  %9d  %8d\n", GC_G(zobj_possible_root), GC_G(zobj_buffered), GC_G(zobj_remove_from_buffer), GC_G(zobj_marked_grey));
     989             : #endif
     990             : 
     991       21286 :         zend_try {
     992       21286 :                 zend_ini_deactivate();
     993       21286 :         } zend_end_try();
     994       21286 : }
     995             : /* }}} */
     996             : 
     997             : BEGIN_EXTERN_C()
     998          34 : ZEND_API void zend_message_dispatcher(zend_long message, const void *data) /* {{{ */
     999             : {
    1000          34 :         if (zend_message_dispatcher_p) {
    1001          34 :                 zend_message_dispatcher_p(message, data);
    1002             :         }
    1003          31 : }
    1004             : /* }}} */
    1005             : END_EXTERN_C()
    1006             : 
    1007     5321630 : ZEND_API zval *zend_get_configuration_directive(zend_string *name) /* {{{ */
    1008             : {
    1009     5321630 :         if (zend_get_configuration_directive_p) {
    1010     5321630 :                 return zend_get_configuration_directive_p(name);
    1011             :         } else {
    1012           0 :                 return NULL;
    1013             :         }
    1014             : }
    1015             : /* }}} */
    1016             : 
    1017             : #define SAVE_STACK(stack) do { \
    1018             :                 if (CG(stack).top) { \
    1019             :                         memcpy(&stack, &CG(stack), sizeof(zend_stack)); \
    1020             :                         CG(stack).top = CG(stack).max = 0; \
    1021             :                         CG(stack).elements = NULL; \
    1022             :                 } else { \
    1023             :                         stack.top = 0; \
    1024             :                 } \
    1025             :         } while (0)
    1026             : 
    1027             : #define RESTORE_STACK(stack) do { \
    1028             :                 if (stack.top) { \
    1029             :                         zend_stack_destroy(&CG(stack)); \
    1030             :                         memcpy(&CG(stack), &stack, sizeof(zend_stack)); \
    1031             :                 } \
    1032             :         } while (0)
    1033             : 
    1034             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1035      385559 : ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) /* {{{ */
    1036             : #else
    1037             : static ZEND_COLD void zend_error_va_list(int type, const char *format, va_list args)
    1038             : #endif
    1039             : {
    1040             :         char *str;
    1041             :         int len;
    1042             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1043             :         va_list args;
    1044             : #endif
    1045             :         va_list usr_copy;
    1046             :         zval params[5];
    1047             :         zval retval;
    1048             :         const char *error_filename;
    1049      385559 :         uint error_lineno = 0;
    1050             :         zval orig_user_error_handler;
    1051             :         zend_bool in_compilation;
    1052             :         zend_class_entry *saved_class_entry;
    1053             :         zend_stack loop_var_stack;
    1054             :         zend_stack delayed_oplines_stack;
    1055             :         zend_array *symbol_table;
    1056             : 
    1057             :         /* Report about uncaught exception in case of fatal errors */
    1058      385559 :         if (EG(exception)) {
    1059             :                 zend_execute_data *ex;
    1060             :                 const zend_op *opline;
    1061             : 
    1062          51 :                 switch (type) {
    1063             :                         case E_CORE_ERROR:
    1064             :                         case E_ERROR:
    1065             :                         case E_RECOVERABLE_ERROR:
    1066             :                         case E_PARSE:
    1067             :                         case E_COMPILE_ERROR:
    1068             :                         case E_USER_ERROR:
    1069           9 :                                 ex = EG(current_execute_data);
    1070           9 :                                 opline = NULL;
    1071          26 :                                 while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
    1072           8 :                                         ex = ex->prev_execute_data;
    1073             :                                 }
    1074          10 :                                 if (ex && ex->opline->opcode == ZEND_HANDLE_EXCEPTION &&
    1075           1 :                                     EG(opline_before_exception)) {
    1076           1 :                                         opline = EG(opline_before_exception);
    1077             :                                 }
    1078           9 :                                 zend_exception_error(EG(exception), E_WARNING);
    1079           9 :                                 EG(exception) = NULL;
    1080           9 :                                 if (opline) {
    1081           1 :                                         ex->opline = opline;
    1082             :                                 }
    1083             :                                 break;
    1084             :                         default:
    1085             :                                 break;
    1086             :                 }
    1087             :         }
    1088             : 
    1089             :         /* Obtain relevant filename and lineno */
    1090      385559 :         switch (type) {
    1091             :                 case E_CORE_ERROR:
    1092             :                 case E_CORE_WARNING:
    1093           5 :                         error_filename = NULL;
    1094           5 :                         error_lineno = 0;
    1095           5 :                         break;
    1096             :                 case E_PARSE:
    1097             :                 case E_COMPILE_ERROR:
    1098             :                 case E_COMPILE_WARNING:
    1099             :                 case E_ERROR:
    1100             :                 case E_NOTICE:
    1101             :                 case E_STRICT:
    1102             :                 case E_DEPRECATED:
    1103             :                 case E_WARNING:
    1104             :                 case E_USER_ERROR:
    1105             :                 case E_USER_WARNING:
    1106             :                 case E_USER_NOTICE:
    1107             :                 case E_USER_DEPRECATED:
    1108             :                 case E_RECOVERABLE_ERROR:
    1109      385554 :                         if (zend_is_compiling()) {
    1110         346 :                                 error_filename = ZSTR_VAL(zend_get_compiled_filename());
    1111         346 :                                 error_lineno = zend_get_compiled_lineno();
    1112      385208 :                         } else if (zend_is_executing()) {
    1113      385173 :                                 error_filename = zend_get_executed_filename();
    1114      385173 :                                 if (error_filename[0] == '[') { /* [no active file] */
    1115           6 :                                         error_filename = NULL;
    1116           6 :                                         error_lineno = 0;
    1117             :                                 } else {
    1118      385167 :                                         error_lineno = zend_get_executed_lineno();
    1119             :                                 }
    1120             :                         } else {
    1121          35 :                                 error_filename = NULL;
    1122          35 :                                 error_lineno = 0;
    1123             :                         }
    1124      385554 :                         break;
    1125             :                 default:
    1126           0 :                         error_filename = NULL;
    1127           0 :                         error_lineno = 0;
    1128             :                         break;
    1129             :         }
    1130      385559 :         if (!error_filename) {
    1131          46 :                 error_filename = "Unknown";
    1132             :         }
    1133             : 
    1134             : #ifdef HAVE_DTRACE
    1135             :         if (DTRACE_ERROR_ENABLED()) {
    1136             :                 char *dtrace_error_buffer;
    1137             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1138             :                 va_start(args, format);
    1139             : #endif
    1140             :                 zend_vspprintf(&dtrace_error_buffer, 0, format, args);
    1141             :                 DTRACE_ERROR(dtrace_error_buffer, (char *)error_filename, error_lineno);
    1142             :                 efree(dtrace_error_buffer);
    1143             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1144             :                 va_end(args);
    1145             : #endif
    1146             :         }
    1147             : #endif /* HAVE_DTRACE */
    1148             : 
    1149             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1150      385559 :         va_start(args, format);
    1151             : #endif
    1152             : 
    1153             :         /* if we don't have a user defined error handler */
    1154      772836 :         if (Z_TYPE(EG(user_error_handler)) == IS_UNDEF
    1155        2172 :                 || !(EG(user_error_handler_error_reporting) & type)
    1156        2145 :                 || EG(error_handling) != EH_NORMAL) {
    1157      383414 :                 zend_error_cb(type, error_filename, error_lineno, format, args);
    1158        2145 :         } else switch (type) {
    1159             :                 case E_ERROR:
    1160             :                 case E_PARSE:
    1161             :                 case E_CORE_ERROR:
    1162             :                 case E_CORE_WARNING:
    1163             :                 case E_COMPILE_ERROR:
    1164             :                 case E_COMPILE_WARNING:
    1165             :                         /* The error may not be safe to handle in user-space */
    1166           5 :                         zend_error_cb(type, error_filename, error_lineno, format, args);
    1167           0 :                         break;
    1168             :                 default:
    1169             :                         /* Handle the error in user space */
    1170             : /* va_copy() is __va_copy() in old gcc versions.
    1171             :  * According to the autoconf manual, using
    1172             :  * memcpy(&dst, &src, sizeof(va_list))
    1173             :  * gives maximum portability. */
    1174             : #ifndef va_copy
    1175             : # ifdef __va_copy
    1176             : #  define va_copy(dest, src)    __va_copy((dest), (src))
    1177             : # else
    1178             : #  define va_copy(dest, src)    memcpy(&(dest), &(src), sizeof(va_list))
    1179             : # endif
    1180             : #endif
    1181        2140 :                         va_copy(usr_copy, args);
    1182        2140 :                         len = (int)zend_vspprintf(&str, 0, format, usr_copy);
    1183        4280 :                         ZVAL_NEW_STR(&params[1], zend_string_init(str, len, 0));
    1184        2140 :                         efree(str);
    1185             : #ifdef va_copy
    1186        2140 :                         va_end(usr_copy);
    1187             : #endif
    1188             : 
    1189        2140 :                         ZVAL_LONG(&params[0], type);
    1190             : 
    1191        2140 :                         if (error_filename) {
    1192        4280 :                                 ZVAL_STRING(&params[2], error_filename);
    1193             :                         } else {
    1194           0 :                                 ZVAL_NULL(&params[2]);
    1195             :                         }
    1196             : 
    1197        2140 :                         ZVAL_LONG(&params[3], error_lineno);
    1198             : 
    1199        2140 :                         symbol_table = zend_rebuild_symbol_table();
    1200             : 
    1201             :                         /* during shutdown the symbol table table can be still null */
    1202        2140 :                         if (!symbol_table) {
    1203           0 :                                 ZVAL_NULL(&params[4]);
    1204             :                         } else {
    1205        2140 :                                 ZVAL_ARR(&params[4], zend_array_dup(symbol_table));
    1206             :                         }
    1207             : 
    1208        2140 :                         ZVAL_COPY_VALUE(&orig_user_error_handler, &EG(user_error_handler));
    1209        2140 :                         ZVAL_UNDEF(&EG(user_error_handler));
    1210             : 
    1211             :                         /* User error handler may include() additinal PHP files.
    1212             :                          * If an error was generated during comilation PHP will compile
    1213             :                          * such scripts recursivly, but some CG() variables may be
    1214             :                          * inconsistent. */
    1215             : 
    1216        2140 :                         in_compilation = CG(in_compilation);
    1217        2140 :                         if (in_compilation) {
    1218           5 :                                 saved_class_entry = CG(active_class_entry);
    1219           5 :                                 CG(active_class_entry) = NULL;
    1220           5 :                                 SAVE_STACK(loop_var_stack);
    1221           5 :                                 SAVE_STACK(delayed_oplines_stack);
    1222           5 :                                 CG(in_compilation) = 0;
    1223             :                         }
    1224             : 
    1225        2140 :                         if (call_user_function_ex(CG(function_table), NULL, &orig_user_error_handler, &retval, 5, params, 1, NULL) == SUCCESS) {
    1226        2140 :                                 if (Z_TYPE(retval) != IS_UNDEF) {
    1227        2116 :                                         if (Z_TYPE(retval) == IS_FALSE) {
    1228           3 :                                                 zend_error_cb(type, error_filename, error_lineno, format, args);
    1229             :                                         }
    1230        2116 :                                         zval_ptr_dtor(&retval);
    1231             :                                 }
    1232           0 :                         } else if (!EG(exception)) {
    1233             :                                 /* The user error handler failed, use built-in error handler */
    1234           0 :                                 zend_error_cb(type, error_filename, error_lineno, format, args);
    1235             :                         }
    1236             : 
    1237        2140 :                         if (in_compilation) {
    1238           5 :                                 CG(active_class_entry) = saved_class_entry;
    1239           5 :                                 RESTORE_STACK(loop_var_stack);
    1240           5 :                                 RESTORE_STACK(delayed_oplines_stack);
    1241           5 :                                 CG(in_compilation) = 1;
    1242             :                         }
    1243             : 
    1244        2140 :                         zval_ptr_dtor(&params[4]);
    1245        2140 :                         zval_ptr_dtor(&params[3]);
    1246        2140 :                         zval_ptr_dtor(&params[2]);
    1247        2140 :                         zval_ptr_dtor(&params[1]);
    1248        2140 :                         zval_ptr_dtor(&params[0]);
    1249             : 
    1250        2140 :                         if (Z_TYPE(EG(user_error_handler)) == IS_UNDEF) {
    1251        2140 :                                 ZVAL_COPY_VALUE(&EG(user_error_handler), &orig_user_error_handler);
    1252             :                         } else {
    1253           0 :                                 zval_ptr_dtor(&orig_user_error_handler);
    1254             :                         }
    1255             :                         break;
    1256             :         }
    1257             : 
    1258             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1259      385100 :         va_end(args);
    1260             : #endif
    1261             : 
    1262      385100 :         if (type == E_PARSE) {
    1263             :                 /* eval() errors do not affect exit_status */
    1264           0 :                 if (!(EG(current_execute_data) &&
    1265           0 :                         EG(current_execute_data)->func &&
    1266           0 :                         ZEND_USER_CODE(EG(current_execute_data)->func->type) &&
    1267           0 :                         EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL &&
    1268           0 :                         EG(current_execute_data)->opline->extended_value == ZEND_EVAL)) {
    1269           0 :                         EG(exit_status) = 255;
    1270             :                 }
    1271             :         }
    1272      385100 : }
    1273             : /* }}} */
    1274             : 
    1275             : #ifdef HAVE_NORETURN
    1276             : # ifdef HAVE_NORETURN_ALIAS
    1277             : ZEND_COLD void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn));
    1278             : # else
    1279             : ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) /* {{{ */
    1280             : {
    1281             :         va_list va;
    1282             : 
    1283             :         va_start(va, format);
    1284             :         zend_error_va_list(type, format, va);
    1285             :         va_end(va);
    1286             : }
    1287             : 
    1288             : ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...)
    1289             : {
    1290             :         va_list va;
    1291             : 
    1292             :         va_start(va, format);
    1293             :         zend_error_va_list(type, format, va);
    1294             :         va_end(va);
    1295             : }
    1296             : /* }}} */
    1297             : # endif
    1298             : #endif
    1299             : 
    1300         322 : ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format, ...) /* {{{ */
    1301             : {
    1302             :         va_list va;
    1303         322 :         char *message = NULL;
    1304             :         
    1305         322 :         if (exception_ce) {
    1306          10 :                 if (!instanceof_function(exception_ce, zend_ce_error)) {
    1307           0 :                         zend_error(E_NOTICE, "Error exceptions must be derived from Error");
    1308           0 :                         exception_ce = zend_ce_error;
    1309             :                 }
    1310             :         } else {
    1311         312 :                 exception_ce = zend_ce_error;
    1312             :         }
    1313             : 
    1314         322 :         va_start(va, format);
    1315         322 :         zend_vspprintf(&message, 0, format, va);
    1316             : 
    1317             :         //TODO: we can't convert compile-time errors to exceptions yet???
    1318         641 :         if (EG(current_execute_data) && !CG(in_compilation)) {
    1319         319 :                 zend_throw_exception(exception_ce, message, 0);
    1320             :         } else {
    1321           3 :                 zend_error(E_ERROR, message);
    1322             :         }
    1323             : 
    1324         319 :         efree(message);
    1325         319 :         va_end(va);
    1326         319 : }
    1327             : /* }}} */
    1328             : 
    1329         382 : ZEND_API ZEND_COLD void zend_type_error(const char *format, ...) /* {{{ */
    1330             : {
    1331             :         va_list va;
    1332         382 :         char *message = NULL;
    1333             : 
    1334         382 :         va_start(va, format);
    1335         382 :         zend_vspprintf(&message, 0, format, va);
    1336         382 :         zend_throw_exception(zend_ce_type_error, message, 0);
    1337         382 :         efree(message);
    1338         382 :         va_end(va);
    1339         382 : } /* }}} */
    1340             : 
    1341       10947 : ZEND_API ZEND_COLD void zend_internal_type_error(zend_bool throw_exception, const char *format, ...) /* {{{ */
    1342             : {
    1343             :         va_list va;
    1344       10947 :         char *message = NULL;
    1345             : 
    1346       10947 :         va_start(va, format);
    1347       10947 :         zend_vspprintf(&message, 0, format, va);
    1348       10947 :         if (throw_exception) {
    1349         111 :                 zend_throw_exception(zend_ce_type_error, message, 0);
    1350             :         } else {
    1351       10836 :                 zend_error(E_WARNING, message);
    1352             :         }
    1353       10947 :         efree(message);
    1354             : 
    1355       10947 :         va_end(va);
    1356       10947 : } /* }}} */
    1357             : 
    1358           0 : ZEND_API ZEND_COLD void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) /* {{{ */
    1359             : {
    1360             : #if ZEND_DEBUG
    1361             :         va_list args;
    1362             : 
    1363             :         va_start(args, format);
    1364             : #       ifdef ZEND_WIN32
    1365             :         {
    1366             :                 char output_buf[1024];
    1367             : 
    1368             :                 vsnprintf(output_buf, 1024, format, args);
    1369             :                 OutputDebugString(output_buf);
    1370             :                 OutputDebugString("\n");
    1371             :                 if (trigger_break && IsDebuggerPresent()) {
    1372             :                         DebugBreak();
    1373             :                 }
    1374             :         }
    1375             : #       else
    1376             :         vfprintf(stderr, format, args);
    1377             :         fprintf(stderr, "\n");
    1378             : #       endif
    1379             :         va_end(args);
    1380             : #endif
    1381           0 : }
    1382             : /* }}} */
    1383             : 
    1384       21192 : ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...) /* {{{ */
    1385             : {
    1386             :         va_list files;
    1387             :         int i;
    1388             :         zend_file_handle *file_handle;
    1389             :         zend_op_array *op_array;
    1390             : 
    1391       21192 :         va_start(files, file_count);
    1392       80813 :         for (i = 0; i < file_count; i++) {
    1393       61594 :                 file_handle = va_arg(files, zend_file_handle *);
    1394       61594 :                 if (!file_handle) {
    1395       40402 :                         continue;
    1396             :                 }
    1397             : 
    1398       21192 :                 op_array = zend_compile_file(file_handle, type);
    1399       20954 :                 if (file_handle->opened_path) {
    1400       20951 :                         zend_hash_add_empty_element(&EG(included_files), file_handle->opened_path);
    1401             :                 }
    1402       20954 :                 zend_destroy_file_handle(file_handle);
    1403       20954 :                 if (op_array) {
    1404       20921 :                         zend_execute(op_array, retval);
    1405       19680 :                         zend_exception_restore();
    1406       19680 :                         if (EG(exception)) {
    1407         475 :                                 if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
    1408             :                                         zval orig_user_exception_handler;
    1409             :                                         zval params[1], retval2;
    1410             :                                         zend_object *old_exception;
    1411          10 :                                         old_exception = EG(exception);
    1412          10 :                                         EG(exception) = NULL;
    1413          10 :                                         ZVAL_OBJ(&params[0], old_exception);
    1414          10 :                                         ZVAL_COPY_VALUE(&orig_user_exception_handler, &EG(user_exception_handler));
    1415             : 
    1416          10 :                                         if (call_user_function_ex(CG(function_table), NULL, &orig_user_exception_handler, &retval2, 1, params, 1, NULL) == SUCCESS) {
    1417           8 :                                                 zval_ptr_dtor(&retval2);
    1418           8 :                                                 if (EG(exception)) {
    1419           0 :                                                         OBJ_RELEASE(EG(exception));
    1420           0 :                                                         EG(exception) = NULL;
    1421             :                                                 }
    1422             :                                                 OBJ_RELEASE(old_exception);
    1423             :                                         } else {
    1424           0 :                                                 EG(exception) = old_exception;
    1425           0 :                                                 zend_exception_error(EG(exception), E_ERROR);
    1426             :                                         }
    1427             :                                 } else {
    1428         465 :                                         zend_exception_error(EG(exception), E_ERROR);
    1429             :                                 }
    1430             :                         }
    1431       19219 :                         destroy_op_array(op_array);
    1432       19219 :                         efree_size(op_array, sizeof(zend_op_array));
    1433          33 :                 } else if (type==ZEND_REQUIRE) {
    1434          33 :                         va_end(files);
    1435          33 :                         return FAILURE;
    1436             :                 }
    1437             :         }
    1438       19219 :         va_end(files);
    1439             : 
    1440       19219 :         return SUCCESS;
    1441             : }
    1442             : /* }}} */
    1443             : 
    1444             : #define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%d) : %s"
    1445             : 
    1446        1083 : ZEND_API char *zend_make_compiled_string_description(const char *name) /* {{{ */
    1447             : {
    1448             :         const char *cur_filename;
    1449             :         int cur_lineno;
    1450             :         char *compiled_string_description;
    1451             : 
    1452        1083 :         if (zend_is_compiling()) {
    1453           0 :                 cur_filename = ZSTR_VAL(zend_get_compiled_filename());
    1454           0 :                 cur_lineno = zend_get_compiled_lineno();
    1455        1083 :         } else if (zend_is_executing()) {
    1456        1083 :                 cur_filename = zend_get_executed_filename();
    1457        1083 :                 cur_lineno = zend_get_executed_lineno();
    1458             :         } else {
    1459           0 :                 cur_filename = "Unknown";
    1460           0 :                 cur_lineno = 0;
    1461             :         }
    1462             : 
    1463        1083 :         zend_spprintf(&compiled_string_description, 0, COMPILED_STRING_DESCRIPTION_FORMAT, cur_filename, cur_lineno, name);
    1464        1083 :         return compiled_string_description;
    1465             : }
    1466             : /* }}} */
    1467             : 
    1468       21122 : void free_estring(char **str_p) /* {{{ */
    1469             : {
    1470       21122 :         efree(*str_p);
    1471       21122 : }
    1472             : /* }}} */
    1473             : 
    1474       29622 : void free_string_zval(zval *zv) /* {{{ */
    1475             : {
    1476       29622 :         zend_string *str = Z_PTR_P(zv);
    1477             :         zend_string_release(str);
    1478       29622 : }
    1479             : /* }}} */
    1480             : 
    1481             : /*
    1482             :  * Local variables:
    1483             :  * tab-width: 4
    1484             :  * c-basic-offset: 4
    1485             :  * indent-tabs-mode: t
    1486             :  * End:
    1487             :  */

Generated by: LCOV version 1.10

Generated at Sat, 29 Aug 2015 10:22:12 +0000 (13 hours ago)

Copyright © 2005-2015 The PHP Group
All rights reserved.