[PHP-CVS] cvs: php-src(PHP_5_2) /sapi/embed php_embed.c

2008-03-26 Thread Marcus Boerger
helly   Wed Mar 26 13:21:57 2008 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/sapi/embed php_embed.c 
  Log:
  MFH:
  - Fix memory leak found by Osman
  - Merge strlen to sizof change from CLI
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/embed/php_embed.c?r1=1.11.2.1.2.6&r2=1.11.2.1.2.7&diff_format=u
Index: php-src/sapi/embed/php_embed.c
diff -u php-src/sapi/embed/php_embed.c:1.11.2.1.2.6 
php-src/sapi/embed/php_embed.c:1.11.2.1.2.7
--- php-src/sapi/embed/php_embed.c:1.11.2.1.2.6 Mon Dec 31 07:20:16 2007
+++ php-src/sapi/embed/php_embed.c  Wed Mar 26 13:21:57 2008
@@ -15,7 +15,7 @@
| Author: Edin Kadribasic <[EMAIL PROTECTED]>  |
+--+
 */
-/* $Id: php_embed.c,v 1.11.2.1.2.6 2007/12/31 07:20:16 sebastian Exp $ */
+/* $Id: php_embed.c,v 1.11.2.1.2.7 2008/03/26 13:21:57 helly Exp $ */
 
 #include "php_embed.h"
 
@@ -24,13 +24,13 @@
 #include 
 #endif
 
-#define HARDCODED_INI  \
-   "html_errors=0\n"   \
-   "register_argc_argv=1\n"\
-   "implicit_flush=1\n"\
-   "output_buffering=0\n"  \
-   "max_execution_time=0\n"\
-   "max_input_time=-1\n"
+const char HARDCODED_INI[] =
+   "html_errors=0\n"
+   "register_argc_argv=1\n"
+   "implicit_flush=1\n"
+   "output_buffering=0\n"
+   "max_execution_time=0\n"
+   "max_input_time=-1\n\0";
 
 static char* php_embed_read_cookies(TSRMLS_D)
 {
@@ -145,7 +145,6 @@
 #ifdef ZTS
void ***tsrm_ls = NULL;
 #endif
-   int ini_entries_len = 0;
 
 #ifdef HAVE_SIGNAL_H
 #if defined(SIGPIPE) && defined(SIG_IGN)
@@ -158,26 +157,24 @@
 #endif
 #endif
 
-#ifdef PHP_WIN32
-  _fmode = _O_BINARY;  /*sets default for file streams to 
binary */
-  setmode(_fileno(stdin), O_BINARY);   /* make the stdio mode be 
binary */
-  setmode(_fileno(stdout), O_BINARY);  /* make the stdio mode be 
binary */
-  setmode(_fileno(stderr), O_BINARY);  /* make the stdio mode be 
binary */
-#endif
-
 #ifdef ZTS
   tsrm_startup(1, 1, 0, NULL);
   tsrm_ls = ts_resource(0);
   *ptsrm_ls = tsrm_ls;
 #endif
 
-  ini_entries_len = strlen(HARDCODED_INI);
-  php_embed_module.ini_entries = malloc(ini_entries_len+2);
-  memcpy(php_embed_module.ini_entries, HARDCODED_INI, ini_entries_len+1);
-  php_embed_module.ini_entries[ini_entries_len+1] = 0;
-
   sapi_startup(&php_embed_module);
 
+#ifdef PHP_WIN32
+  _fmode = _O_BINARY;  /*sets default for file streams to 
binary */
+  setmode(_fileno(stdin), O_BINARY);   /* make the stdio mode be 
binary */
+  setmode(_fileno(stdout), O_BINARY);  /* make the stdio mode be 
binary */
+  setmode(_fileno(stderr), O_BINARY);  /* make the stdio mode be 
binary */
+#endif
+
+  php_embed_module.ini_entries = malloc(sizeof(HARDCODED_INI));
+  memcpy(php_embed_module.ini_entries, HARDCODED_INI, sizeof(HARDCODED_INI));
+
   if (argv) {
php_embed_module.executable_location = argv[0];
   }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /sapi/embed php_embed.c

2007-08-08 Thread Stanislav Malyshev
stasWed Aug  8 21:57:30 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/sapi/embed php_embed.c 
  Log:
  fix startup - remove unneeded variables
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/embed/php_embed.c?r1=1.11.2.1.2.4&r2=1.11.2.1.2.5&diff_format=u
Index: php-src/sapi/embed/php_embed.c
diff -u php-src/sapi/embed/php_embed.c:1.11.2.1.2.4 
php-src/sapi/embed/php_embed.c:1.11.2.1.2.5
--- php-src/sapi/embed/php_embed.c:1.11.2.1.2.4 Wed Aug  8 21:11:53 2007
+++ php-src/sapi/embed/php_embed.c  Wed Aug  8 21:57:30 2007
@@ -15,7 +15,7 @@
| Author: Edin Kadribasic <[EMAIL PROTECTED]>  |
+--+
 */
-/* $Id: php_embed.c,v 1.11.2.1.2.4 2007/08/08 21:11:53 stas Exp $ */
+/* $Id: php_embed.c,v 1.11.2.1.2.5 2007/08/08 21:57:30 stas Exp $ */
 
 #include "php_embed.h"
 
@@ -143,7 +143,6 @@
 {
zend_llist global_vars;
 #ifdef ZTS
-   sapi_globals_struct *sapi_globals = NULL;
void ***tsrm_ls = NULL;
 #endif
int ini_entries_len = 0;
@@ -168,6 +167,8 @@
 
 #ifdef ZTS
   tsrm_startup(1, 1, 0, NULL);
+  tsrm_ls = ts_resource(0);
+  *ptsrm_ls = tsrm_ls;
 #endif
 
   ini_entries_len = strlen(HARDCODED_INI);
@@ -185,12 +186,6 @@
  return FAILURE;
   }
  
-#ifdef ZTS
-  sapi_globals = ts_resource(sapi_globals_id);
-  tsrm_ls = ts_resource(0);
-  *ptsrm_ls = tsrm_ls;
-#endif
-
   zend_llist_init(&global_vars, sizeof(char *), NULL, 0);  
 
   /* Set some Embedded PHP defaults */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /sapi/embed php_embed.c

2007-08-08 Thread Stanislav Malyshev
stasWed Aug  8 21:11:53 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/sapi/embed php_embed.c 
  Log:
  initialize values
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/embed/php_embed.c?r1=1.11.2.1.2.3&r2=1.11.2.1.2.4&diff_format=u
Index: php-src/sapi/embed/php_embed.c
diff -u php-src/sapi/embed/php_embed.c:1.11.2.1.2.3 
php-src/sapi/embed/php_embed.c:1.11.2.1.2.4
--- php-src/sapi/embed/php_embed.c:1.11.2.1.2.3 Wed Aug  8 21:06:28 2007
+++ php-src/sapi/embed/php_embed.c  Wed Aug  8 21:11:53 2007
@@ -15,7 +15,7 @@
| Author: Edin Kadribasic <[EMAIL PROTECTED]>  |
+--+
 */
-/* $Id: php_embed.c,v 1.11.2.1.2.3 2007/08/08 21:06:28 stas Exp $ */
+/* $Id: php_embed.c,v 1.11.2.1.2.4 2007/08/08 21:11:53 stas Exp $ */
 
 #include "php_embed.h"
 
@@ -143,8 +143,8 @@
 {
zend_llist global_vars;
 #ifdef ZTS
-   sapi_globals_struct *sapi_globals;
-   void ***tsrm_ls;
+   sapi_globals_struct *sapi_globals = NULL;
+   void ***tsrm_ls = NULL;
 #endif
int ini_entries_len = 0;
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /sapi/embed php_embed.c

2007-08-08 Thread Stanislav Malyshev
stasWed Aug  8 21:06:28 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/sapi/embed php_embed.c 
  Log:
  fix TSRM embed startup
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/embed/php_embed.c?r1=1.11.2.1.2.2&r2=1.11.2.1.2.3&diff_format=u
Index: php-src/sapi/embed/php_embed.c
diff -u php-src/sapi/embed/php_embed.c:1.11.2.1.2.2 
php-src/sapi/embed/php_embed.c:1.11.2.1.2.3
--- php-src/sapi/embed/php_embed.c:1.11.2.1.2.2 Thu Aug  2 23:45:28 2007
+++ php-src/sapi/embed/php_embed.c  Wed Aug  8 21:06:28 2007
@@ -15,7 +15,7 @@
| Author: Edin Kadribasic <[EMAIL PROTECTED]>  |
+--+
 */
-/* $Id: php_embed.c,v 1.11.2.1.2.2 2007/08/02 23:45:28 stas Exp $ */
+/* $Id: php_embed.c,v 1.11.2.1.2.3 2007/08/08 21:06:28 stas Exp $ */
 
 #include "php_embed.h"
 
@@ -143,9 +143,6 @@
 {
zend_llist global_vars;
 #ifdef ZTS
-   zend_compiler_globals *compiler_globals;
-   zend_executor_globals *executor_globals;
-   php_core_globals *core_globals;
sapi_globals_struct *sapi_globals;
void ***tsrm_ls;
 #endif
@@ -173,15 +170,6 @@
   tsrm_startup(1, 1, 0, NULL);
 #endif
 
-#ifdef ZTS
-  compiler_globals = ts_resource(compiler_globals_id);
-  executor_globals = ts_resource(executor_globals_id);
-  core_globals = ts_resource(core_globals_id);
-  sapi_globals = ts_resource(sapi_globals_id);
-  tsrm_ls = ts_resource(0);
-  *ptsrm_ls = tsrm_ls;
-#endif
-
   ini_entries_len = strlen(HARDCODED_INI);
   php_embed_module.ini_entries = malloc(ini_entries_len+2);
   memcpy(php_embed_module.ini_entries, HARDCODED_INI, ini_entries_len+1);
@@ -189,24 +177,24 @@
 
   sapi_startup(&php_embed_module);
 
+  if (argv) {
+   php_embed_module.executable_location = argv[0];
+  }
+
   if (php_embed_module.startup(&php_embed_module)==FAILURE) {
  return FAILURE;
   }
  
-  if (argv) {
-   php_embed_module.executable_location = argv[0];
-  }
+#ifdef ZTS
+  sapi_globals = ts_resource(sapi_globals_id);
+  tsrm_ls = ts_resource(0);
+  *ptsrm_ls = tsrm_ls;
+#endif
 
   zend_llist_init(&global_vars, sizeof(char *), NULL, 0);  
 
   /* Set some Embedded PHP defaults */
   SG(options) |= SAPI_OPTION_NO_CHDIR;
-#if 0
-//  zend_alter_ini_entry("register_argc_argv", 19, "1", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
-//  zend_alter_ini_entry("html_errors", 12, "0", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
-//  zend_alter_ini_entry("implicit_flush", 15, "1", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
-//  zend_alter_ini_entry("max_execution_time", 19, "0", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
-#endif
   SG(request_info).argc=argc;
   SG(request_info).argv=argv;
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /sapi/embed php_embed.c

2007-08-02 Thread Stanislav Malyshev
stasThu Aug  2 23:45:28 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/sapi/embed php_embed.c 
  Log:
  use hardcoded ini like CLI
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/embed/php_embed.c?r1=1.11.2.1.2.1&r2=1.11.2.1.2.2&diff_format=u
Index: php-src/sapi/embed/php_embed.c
diff -u php-src/sapi/embed/php_embed.c:1.11.2.1.2.1 
php-src/sapi/embed/php_embed.c:1.11.2.1.2.2
--- php-src/sapi/embed/php_embed.c:1.11.2.1.2.1 Mon Jan  1 09:36:12 2007
+++ php-src/sapi/embed/php_embed.c  Thu Aug  2 23:45:28 2007
@@ -15,7 +15,7 @@
| Author: Edin Kadribasic <[EMAIL PROTECTED]>  |
+--+
 */
-/* $Id: php_embed.c,v 1.11.2.1.2.1 2007/01/01 09:36:12 sebastian Exp $ */
+/* $Id: php_embed.c,v 1.11.2.1.2.2 2007/08/02 23:45:28 stas Exp $ */
 
 #include "php_embed.h"
 
@@ -24,6 +24,14 @@
 #include 
 #endif
 
+#define HARDCODED_INI  \
+   "html_errors=0\n"   \
+   "register_argc_argv=1\n"\
+   "implicit_flush=1\n"\
+   "output_buffering=0\n"  \
+   "max_execution_time=0\n"\
+   "max_input_time=-1\n"
+
 static char* php_embed_read_cookies(TSRMLS_D)
 {
return NULL;
@@ -141,6 +149,7 @@
sapi_globals_struct *sapi_globals;
void ***tsrm_ls;
 #endif
+   int ini_entries_len = 0;
 
 #ifdef HAVE_SIGNAL_H
 #if defined(SIGPIPE) && defined(SIG_IGN)
@@ -173,6 +182,11 @@
   *ptsrm_ls = tsrm_ls;
 #endif
 
+  ini_entries_len = strlen(HARDCODED_INI);
+  php_embed_module.ini_entries = malloc(ini_entries_len+2);
+  memcpy(php_embed_module.ini_entries, HARDCODED_INI, ini_entries_len+1);
+  php_embed_module.ini_entries[ini_entries_len+1] = 0;
+
   sapi_startup(&php_embed_module);
 
   if (php_embed_module.startup(&php_embed_module)==FAILURE) {
@@ -187,11 +201,12 @@
 
   /* Set some Embedded PHP defaults */
   SG(options) |= SAPI_OPTION_NO_CHDIR;
-  zend_alter_ini_entry("register_argc_argv", 19, "1", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
-  zend_alter_ini_entry("html_errors", 12, "0", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
-  zend_alter_ini_entry("implicit_flush", 15, "1", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
-  zend_alter_ini_entry("max_execution_time", 19, "0", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
-
+#if 0
+//  zend_alter_ini_entry("register_argc_argv", 19, "1", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
+//  zend_alter_ini_entry("html_errors", 12, "0", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
+//  zend_alter_ini_entry("implicit_flush", 15, "1", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
+//  zend_alter_ini_entry("max_execution_time", 19, "0", 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
+#endif
   SG(request_info).argc=argc;
   SG(request_info).argv=argv;
 
@@ -215,6 +230,10 @@
 #ifdef ZTS
 tsrm_shutdown();
 #endif
+   if (php_embed_module.ini_entries) {
+   free(php_embed_module.ini_entries);
+   php_embed_module.ini_entries = NULL;
+   }
 }
 
 /*

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php