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);
}
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 */
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)
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])) {
}
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);