]> granicus.if.org Git - php/commitdiff
- Create dtor function
authorAndi Gutmans <andi@php.net>
Sun, 2 Apr 2000 20:26:06 +0000 (20:26 +0000)
committerAndi Gutmans <andi@php.net>
Sun, 2 Apr 2000 20:26:06 +0000 (20:26 +0000)
main/SAPI.c
main/php_virtual_cwd.c
main/php_virtual_cwd.h

index 85892b35017cc94fb271c2a7b646e9265c48bf40..3f29c977691930842a04046205cdde715bd03e9d 100644 (file)
@@ -92,6 +92,9 @@ SAPI_API void sapi_startup(sapi_module_struct *sf)
 SAPI_API void sapi_shutdown(void)
 {
        reentrancy_shutdown();
+#ifdef VIRTUAL_DIR
+       virtual_cwd_shutdown();
+#endif
        php_global_shutdown_internal_extensions();
        zend_hash_destroy(&known_post_content_types);
 }
index 470c28a2b36c9b5919c77ae5db13de4666b66474..8a2ecd0278dbc9b0fff5bf8725eb3e926c440fa4 100644 (file)
@@ -123,6 +123,11 @@ static void cwd_globals_ctor(zend_cwd_globals *cwd_globals)
        CWD_STATE_COPY(&cwd_globals->cwd, &main_cwd_state);
 }
 
+static void cwd_globals_dtor(zend_cwd_globals *cwd_globals)
+{
+       CWD_STATE_FREE(&cwd_globals->cwd);
+}
+
 void virtual_cwd_startup()
 {
        char cwd[1024]; /* Should probably use system define here */
@@ -135,7 +140,15 @@ void virtual_cwd_startup()
        main_cwd_state.cwd = strdup(cwd);
        main_cwd_state.cwd_length = strlen(cwd);
 
-       ZEND_INIT_MODULE_GLOBALS(cwd, cwd_globals_ctor, NULL);
+       ZEND_INIT_MODULE_GLOBALS(cwd, cwd_globals_ctor, cwd_globals_dtor);
+}
+
+void virtual_cwd_shutdown()
+{
+#ifndef ZTS
+       cwd_globals_dtor(&cwd_globals);
+#endif
+       free(main_cwd_state.cwd); /* Don't use CWD_STATE_FREE because the non global states will probably use emalloc()/efree() */
 }
 
 char *virtual_getcwd_ex(int *length)
@@ -291,7 +304,7 @@ int virtual_chdir_file(char *path)
        int length = strlen(path);
 
        if (length == 0) {
-               return 1; /* Can't CD to empty string */
+               return 1; /* Can't cd to empty string */
        }       
        while(--length >= 0 && !IS_SLASH(path[length])) {
        }
index e98bb5344cc92557028d1552302b9241d5f6f359..24fe7e7c8b018b5517f6499fde5494321fccb16b 100644 (file)
@@ -22,6 +22,7 @@ typedef struct _cwd_state {
 typedef int (*verify_path_func)(const cwd_state *);
 
 void virtual_cwd_startup();
+void virtual_cwd_shutdown();
 char *virtual_getcwd_ex(int *length);
 char *virtual_getcwd(char *buf, size_t size);
 int virtual_chdir(char *path);