summaryrefslogtreecommitdiff
path: root/ext/filepro/filepro.c
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2005-02-07 13:30:45 +0000
committerAntony Dovgal <tony2001@php.net>2005-02-07 13:30:45 +0000
commit96610aee0875c8e979559d8490951d28a9ec01b7 (patch)
tree0ca55c0a3d48a25719e154591f5735f80c51ed02 /ext/filepro/filepro.c
parent066d1b4d530d969fea641fed4a381d5b499341e0 (diff)
downloadphp-git-96610aee0875c8e979559d8490951d28a9ec01b7.tar.gz
fix leaks on shutdown
fix leaks appearing when trying to open several "databases"
Diffstat (limited to 'ext/filepro/filepro.c')
-rw-r--r--ext/filepro/filepro.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/ext/filepro/filepro.c b/ext/filepro/filepro.c
index 2821c9aa16..737a1e0c0d 100644
--- a/ext/filepro/filepro.c
+++ b/ext/filepro/filepro.c
@@ -96,11 +96,43 @@ PHP_MINIT_FUNCTION(filepro)
fp_globals = (fp_global_struct *) LocalAlloc(LPTR, sizeof(fp_global_struct));
TlsSetValue(FPTls, (void *) fp_globals);
#endif
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_RINIT_FUNCTION
+ */
+PHP_RINIT_FUNCTION(filepro)
+{
FP_GLOBAL(fp_database)=NULL;
FP_GLOBAL(fp_fcount)=-1;
FP_GLOBAL(fp_keysize)=-1;
FP_GLOBAL(fp_fieldlist)=NULL;
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_RSHUTDOWN_FUNCTION
+ */
+PHP_RSHUTDOWN_FUNCTION(filepro)
+{
+ FP_FIELD *tmp, *next;
+ if (FP_GLOBAL(fp_database)) {
+ efree(FP_GLOBAL(fp_database));
+ }
+
+ if (FP_GLOBAL(fp_fieldlist)) {
+ for (tmp = FP_GLOBAL(fp_fieldlist); tmp;) {
+ efree(tmp->name);
+ efree(tmp->format);
+ next = tmp->next;
+ efree(tmp);
+ tmp=next;
+ }
+ }
return SUCCESS;
}
/* }}} */
@@ -143,7 +175,15 @@ function_entry filepro_functions[] = {
zend_module_entry filepro_module_entry = {
STANDARD_MODULE_HEADER,
- "filepro", filepro_functions, PHP_MINIT(filepro), PHP_MSHUTDOWN(filepro), NULL, NULL, NULL, NO_VERSION_YET, STANDARD_MODULE_PROPERTIES
+ "filepro",
+ filepro_functions,
+ PHP_MINIT(filepro),
+ PHP_MSHUTDOWN(filepro),
+ PHP_RINIT(filepro),
+ PHP_RSHUTDOWN(filepro),
+ NULL,
+ NO_VERSION_YET,
+ STANDARD_MODULE_PROPERTIES
};
@@ -214,6 +254,8 @@ PHP_FUNCTION(filepro)
tmp = FP_GLOBAL(fp_fieldlist);
while (tmp != NULL) {
next = tmp->next;
+ efree(tmp->name);
+ efree(tmp->format);
efree(tmp);
tmp = next;
}