diff options
author | Andrei Zmievski <andrei@php.net> | 2000-10-20 18:25:16 +0000 |
---|---|---|
committer | Andrei Zmievski <andrei@php.net> | 2000-10-20 18:25:16 +0000 |
commit | 7b4983c8f82c4f361df787f58c6f5cf88d5def0b (patch) | |
tree | e38e8ffceb65a0f2492b28e2b07c8668fcddeda4 /ext | |
parent | a0cfab65ea72963f81a3440a3587d11bd7800337 (diff) | |
download | php-git-7b4983c8f82c4f361df787f58c6f5cf88d5def0b.tar.gz |
Mega-patch to get better resource information for modules.
* Fixed a bug in zend_rsrc_list_get_rsrc_type()
* Switched register_list_destructors() to use
zend_register_list_destructors_ex() instead
* Updated all relevant modules to provide the resource type name
to register_list_destructors() call
* Updated var_dump() to output resource type name instead of number
@- Made resource type names visible, e.g. var_dump() and
@ get_resource_type() display "file" for file resources. (Andrei)
Diffstat (limited to 'ext')
43 files changed, 322 insertions, 201 deletions
diff --git a/ext/aspell/aspell.c b/ext/aspell/aspell.c index 986b7ad0e9..c8f667dabe 100644 --- a/ext/aspell/aspell.c +++ b/ext/aspell/aspell.c @@ -52,15 +52,16 @@ zend_module_entry aspell_module_entry = { ZEND_GET_MODULE(aspell) #endif -static void php_aspell_close(aspell *sc) +static void php_aspell_close(zend_rsrc_list_entry *rsrc) { + aspell *sc = (aspell *)rsrc->ptr; aspell_free(sc); } PHP_MINIT_FUNCTION(aspell) { - le_aspell = register_list_destructors(php_aspell_close,NULL); + le_aspell = register_list_destructors(php_aspell_close,NULL,"aspell"); return SUCCESS; } diff --git a/ext/cpdf/cpdf.c b/ext/cpdf/cpdf.c index 5eae693164..b4eade66d9 100644 --- a/ext/cpdf/cpdf.c +++ b/ext/cpdf/cpdf.c @@ -162,19 +162,20 @@ zend_module_entry cpdf_module_entry = { ZEND_GET_MODULE(cpdf) #endif -static void _free_outline(CPDFoutlineEntry *outline) +static void _free_outline(zend_rsrc_list_entry *rsrc) { } -static void _free_doc(CPDFdoc *pdf) +static void _free_doc(zend_rsrc_list_entry *rsrc) { + CPDFdoc *pdf = (CPDFdoc *)rsrc->ptr; cpdf_close(pdf); } PHP_MINIT_FUNCTION(cpdf) { - CPDF_GLOBAL(le_outline) = register_list_destructors(_free_outline, NULL); - CPDF_GLOBAL(le_cpdf) = register_list_destructors(_free_doc, NULL); + CPDF_GLOBAL(le_outline) = register_list_destructors(_free_outline, NULL,"cpdf outline"); + CPDF_GLOBAL(le_cpdf) = register_list_destructors(_free_doc, NULL,"cpdf"); return SUCCESS; } diff --git a/ext/curl/curl.c b/ext/curl/curl.c index 2c07be656a..4b7c6bb336 100644 --- a/ext/curl/curl.c +++ b/ext/curl/curl.c @@ -134,7 +134,7 @@ PHP_MINFO_FUNCTION(curl) PHP_MINIT_FUNCTION(curl) { - le_curl = register_list_destructors(_php_curl_close, NULL); + le_curl = register_list_destructors(_php_curl_close, NULL, "curl"); /* Constants for curl_setopt() */ REGISTER_LONG_CONSTANT("CURLOPT_PORT", CURLOPT_PORT, CONST_CS | CONST_PERSISTENT); @@ -785,8 +785,9 @@ PHP_FUNCTION(curl_close) /* {{{ _php_curl_close() List destructor for curl handles */ -static void _php_curl_close(php_curl *curl_handle) +static void _php_curl_close(zend_rsrc_list_entry *rsrc) { + php_curl *curl_handle = (php_curl *)rsrc->ptr; curl_easy_cleanup(curl_handle->cp); efree(curl_handle); } diff --git a/ext/db/db.c b/ext/db/db.c index aca8d7ea1f..406ef9d3a9 100644 --- a/ext/db/db.c +++ b/ext/db/db.c @@ -423,8 +423,9 @@ PHP_FUNCTION(dbmclose) { } /* }}} */ -int php_dbm_close(dbm_info *info) { +int php_dbm_close(zend_rsrc_list_entry *rsrc) { int ret = 0; + dbm_info *info = (dbm_info *)rsrc->ptr; DBM_TYPE dbf; int lockfd; @@ -1121,7 +1122,7 @@ PHP_MINIT_FUNCTION(db) } #endif - le_db = register_list_destructors(php_dbm_close,NULL); + le_db = register_list_destructors(php_dbm_close,NULL,"dbm"); return SUCCESS; } diff --git a/ext/dba/dba.c b/ext/dba/dba.c index ac552802d6..6d70e11113 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -178,8 +178,9 @@ static HashTable ht_keys; /* {{{ helper routines */ /* {{{ dba_close */ -static void dba_close(dba_info *info) +static void dba_close(zend_rsrc_list_entry *rsrc) { + dba_info *info = (dba_info *)rsrc->ptr; if(info->hnd) info->hnd->close(info); if(info->path) free(info->path); free(info); @@ -189,8 +190,8 @@ static void dba_close(dba_info *info) static PHP_MINIT_FUNCTION(dba) { zend_hash_init(&ht_keys, 0, NULL, NULL, 1); - GLOBAL(le_db) = register_list_destructors(dba_close, NULL); - GLOBAL(le_pdb) = register_list_destructors(NULL, dba_close); + GLOBAL(le_db) = register_list_destructors(dba_close, NULLi,"dba"); + GLOBAL(le_pdb) = register_list_destructors(NULL, dba_close,"dba persistent"); return SUCCESS; } diff --git a/ext/dbase/dbase.c b/ext/dbase/dbase.c index 8738b4f3b2..dbf4706430 100644 --- a/ext/dbase/dbase.c +++ b/ext/dbase/dbase.c @@ -55,8 +55,9 @@ static int le_dbhead; #include <errno.h> -static void _close_dbase(dbhead_t *dbhead) +static void _close_dbase(zend_rsrc_list_entry *rsrc) { + dbhead_t *dbhead = (dbhead_t *)rsrc->ptr; close(dbhead->db_fd); free_dbf_head(dbhead); } @@ -80,7 +81,8 @@ PHP_MINIT_FUNCTION(dbase) dbase_globals = (dbase_global_struct *) LocalAlloc(LPTR, sizeof(dbase_global_struct)); TlsSetValue(DbaseTls, (void *) dbase_globals); #endif - DBase_GLOBAL(le_dbhead) = register_list_destructors(_close_dbase,NULL); + DBase_GLOBAL(le_dbhead) = + register_list_destructors(_close_dbase,NULL,"dbase"); return SUCCESS; } diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index 7ddd1e1c63..49431aac74 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -111,7 +111,13 @@ zend_module_entry domxml_module_entry = { ZEND_GET_MODULE(domxml) #endif -void _free_node(xmlNode *tmp) { +static void php_free_xml_doc(zend_rsrc_list_entry *rsrc) +{ + xmlDoc *doc = (xmlDoc *)rsrc->ptr; + xmlFreeDoc(doc); +} + +void _free_node(zend_rsrc_list_entry *rsrc) { /*fprintf(stderr, "Freeing node: %s\n", tmp->name);*/ } @@ -127,12 +133,12 @@ PHP_MINIT_FUNCTION(domxml) domxmltestnode_class_startup(); #endif - le_domxmldocp = register_list_destructors(xmlFreeDoc, NULL); + le_domxmldocp = register_list_destructors(xmlFreeDoc, NULL, "domxml document"); /* Freeing the document contains freeing the complete tree. Therefore nodes, attributes etc. may not be freed seperately. */ - le_domxmlnodep = register_list_destructors(_free_node, NULL); - le_domxmlattrp = register_list_destructors(NULL, NULL); + le_domxmlnodep = register_list_destructors(_free_node, NULL, "domxml node"); + le_domxmlattrp = register_list_destructors(NULL, NULL, "domxml attribute"); /* le_domxmlnsp = register_list_destructors(NULL, NULL); */ INIT_CLASS_ENTRY(domxmldoc_class_entry, "DomDocument", php_domxmldoc_class_functions); diff --git a/ext/fdf/fdf.c b/ext/fdf/fdf.c index bb1e9f751a..998483d946 100644 --- a/ext/fdf/fdf.c +++ b/ext/fdf/fdf.c @@ -100,7 +100,9 @@ zend_module_entry fdf_module_entry = { ZEND_GET_MODULE(fdf) #endif -static void phpi_FDFClose(FDFDoc fdf) { +static void phpi_FDFClose(zend_rsrc_list_entry *rsrc) +{ + FDFDoc fdf = (FDFDoc)rsrc->ptr; (void)FDFClose(fdf); } @@ -116,7 +118,7 @@ static sapi_post_entry supported_post_entries[] = { PHP_MINIT_FUNCTION(fdf) { FDFErc err; - FDF_GLOBAL(le_fdf) = register_list_destructors(phpi_FDFClose, NULL); + FDF_GLOBAL(le_fdf) = register_list_destructors(phpi_FDFClose, NULL, "fdf"); /* add handler for Acrobat FDF form post requests */ sapi_add_post_entry("application/vnd.fdf", php_default_post_reader, fdf_post_handler); diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index a7de40b128..a457aab211 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -84,14 +84,15 @@ zend_module_entry php_ftp_module_entry = { ZEND_GET_MODULE(php_ftp) #endif -static void ftp_destructor_ftpbuf(ftpbuf_t *ftp) +static void ftp_destructor_ftpbuf(zend_rsrc_list_entry *rsrc) { + ftpbuf_t *ftp = (ftpbuf_t *)rsrc->ptr; ftp_close(ftp); } PHP_MINIT_FUNCTION(ftp) { - le_ftpbuf = register_list_destructors(ftp_destructor_ftpbuf, NULL); + le_ftpbuf = register_list_destructors(ftp_destructor_ftpbuf, NULL, "ftp"); REGISTER_MAIN_LONG_CONSTANT("FTP_ASCII", FTPTYPE_ASCII, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_LONG_CONSTANT("FTP_BINARY", FTPTYPE_IMAGE, diff --git a/ext/gd/gd.c b/ext/gd/gd.c index aaf00b4715..4b5d32102c 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -187,9 +187,14 @@ static php_gd_globals gd_globals; ZEND_GET_MODULE(gd) #endif +static void php_free_gd_image(zend_rsrc_list_entry *rsrc) +{ + gdImageDestroy((gdImagePtr)rsrc->ptr); +} -static void php_free_gd_font(gdFontPtr fp) +static void php_free_gd_font(zend_rsrc_list_entry *rsrc) { + gdFontPtr fp = (gdFontPtr)rsrc->ptr; if (fp->data) { efree(fp->data); } @@ -220,14 +225,14 @@ PHP_MINIT_FUNCTION(gd) return FAILURE; } #endif - GDG(le_gd) = register_list_destructors(gdImageDestroy, NULL); - GDG(le_gd_font) = register_list_destructors(php_free_gd_font, NULL); + GDG(le_gd) = register_list_destructors(php_free_gd_image, NULL, "gd"); + GDG(le_gd_font) = register_list_destructors(php_free_gd_font, NULL, "gd font"); #if HAVE_LIBT1 T1_SetBitmapPad(8); T1_InitLib(NO_LOGFILE|IGNORE_CONFIGFILE|IGNORE_FONTDATABASE); T1_SetLogLevel(T1LOG_DEBUG); - GDG(le_ps_font) = register_list_destructors(php_free_ps_font, NULL); - GDG(le_ps_enc) = register_list_destructors(php_free_ps_enc, NULL); + GDG(le_ps_font) = register_list_destructors(php_free_ps_font, NULL, "gd PS font"); + GDG(le_ps_enc) = register_list_destructors(php_free_ps_enc, NULL, "gd PS encoding"); #endif REGISTER_LONG_CONSTANT("IMG_GIF", 1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMG_JPG", 2, CONST_CS | CONST_PERSISTENT); @@ -2068,14 +2073,16 @@ void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode) #if HAVE_LIBT1 -void php_free_ps_font(int *font) +void php_free_ps_font(zend_rsrc_list_entry *rsrc) { + int *font = (int *)rsrc->ptr; T1_DeleteFont(*font); efree(font); } -void php_free_ps_enc(char **enc) +void php_free_ps_enc(zend_rsrc_list_entry *rsrc) { + char **enc = (char **)rsrc->ptr; T1_DeleteEncoding(enc); } diff --git a/ext/hyperwave/hw.c b/ext/hyperwave/hw.c index e530e92b52..69dbe97c0a 100644 --- a/ext/hyperwave/hw.c +++ b/ext/hyperwave/hw.c @@ -132,8 +132,9 @@ ZEND_GET_MODULE(hw) void print_msg(hg_msg *msg, char *str, int txt); -void _close_hw_link(hw_connection *conn) +void _close_hw_link(zend_rsrc_list_entry *rsrc) { + hw_connection *conn = (hw_connection *)rsrc->ptr; if(conn->hostname) free(conn->hostname); if(conn->username) @@ -143,8 +144,9 @@ void _close_hw_link(hw_connection *conn) HwSG(num_links)--; } -void _close_hw_plink(hw_connection *conn) +void _close_hw_plink(zend_rsrc_list_entry *rsrc) { + hw_connection *conn = (hw_connection *)rsrc->ptr; if(conn->hostname) free(conn->hostname); if(conn->username) @@ -155,8 +157,9 @@ void _close_hw_plink(hw_connection *conn) HwSG(num_persistent)--; } -void _free_hw_document(hw_document *doc) +void _free_hw_document(zend_rsrc_list_entry *rsrc) { + hw_document *doc = (hw_document *)rsrc->ptr; if(doc->data) free(doc->data); if(doc->attributes) @@ -191,9 +194,9 @@ PHP_MINIT_FUNCTION(hw) { ZEND_INIT_MODULE_GLOBALS(hw, php_hw_init_globals, NULL); REGISTER_INI_ENTRIES(); - HwSG(le_socketp) = register_list_destructors(_close_hw_link,NULL); - HwSG(le_psocketp) = register_list_destructors(NULL,_close_hw_plink); - HwSG(le_document) = register_list_destructors(_free_hw_document,NULL); + HwSG(le_socketp) = register_list_destructors(_close_hw_link,NULL, "hyperwave link"); + HwSG(le_psocketp) = register_list_destructors(NULL,_close_hw_plink, "hyperwave link persistent"); + HwSG(le_document) = register_list_destructors(_free_hw_document,NULL, "hyperwave document"); hw_module_entry.type = type; REGISTER_LONG_CONSTANT("HW_ATTR_LANG", HW_ATTR_LANG, CONST_CS | CONST_PERSISTENT); diff --git a/ext/icap/php_icap.c b/ext/icap/php_icap.c index 8e5b4f8b47..6f98c3b151 100644 --- a/ext/icap/php_icap.c +++ b/ext/icap/php_icap.c @@ -116,8 +116,9 @@ int le_picap; char icap_user[80]=""; char icap_password[80]=""; -CALSTREAM *cal_close_it (pils *icap_le_struct) +CALSTREAM *cal_close_it (zend_rsrc_list_entry *rsrc) { + pils *icap_le_struct = (pils *)rsrc->ptr; CALSTREAM *ret; ret = cal_close (icap_le_struct->icap_stream,0); efree(icap_le_struct); @@ -136,7 +137,7 @@ PHP_MINFO_FUNCTION(icap) PHP_MINIT_FUNCTION(icap) { - le_icap = register_list_destructors(cal_close_it,NULL); + le_icap = register_list_destructors(cal_close_it,NULL,"icap"); return SUCCESS; } diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 9a1fc6e061..c8c5f4aeaf 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -71,11 +71,11 @@ void *fs_get(size_t size); int imap_mail(char *to, char *subject, char *message, char *headers, char *cc, char *bcc, char *rpath); -void mail_close_it(pils *imap_le_struct); +void mail_close_it(zend_rsrc_list_entry *rsrc); #ifdef OP_RELOGIN /* AJS: close persistent connection */ -void mail_userlogout_it(pils *imap_le_struct); -void mail_nuke_chain(pils **headp); +void mail_userlogout_it(zend_rsrc_list_entry *rsrc); +void mail_nuke_chain(zend_rsrc_list_entry *rsrc); #endif function_entry imap_functions[] = { @@ -180,16 +180,18 @@ extern char imsp_password[80]; #endif -void mail_close_it(pils *imap_le_struct) +void mail_close_it(zend_rsrc_list_entry *rsrc) { + pils *imap_le_struct = (pils *)rsrc->ptr; mail_close_full(imap_le_struct->imap_stream, imap_le_struct->flags); efree(imap_le_struct); } #ifdef OP_RELOGIN /* AJS: stream close functions for persistent connections */ -void mail_userlogout_it(pils *imap_le_struct) +void mail_userlogout_it(zend_rsrc_list_entry *rsrc) { + pils *imap_le_struct = (pils *)rsrc->ptr; /* Close this user's session, putting the stream back * into AUTHENTICATE state. (Note that IMAP does not * support this behavior... yet) @@ -198,8 +200,9 @@ void mail_userlogout_it(pils *imap_le_struct) mail_close_full(imap_le_struct->imap_stream, imap_le_struct->flags | CL_HALF); } -void mail_nuke_chain(pils **headp) +void mail_nuke_chain(zend_rsrc_list_entry *rsrc) { + pils **headp = (pils **)rsrc->ptr; pils *node, *next; for (node = *headp; node; node = next) { @@ -589,11 +592,11 @@ PHP_MINIT_FUNCTION(imap) ENCOTHER unknown */ - le_imap = register_list_destructors(mail_close_it,NULL); + le_imap = register_list_destructors(mail_close_it,NULL,"imap"); #ifdef OP_RELOGIN /* AJS: destructors for persistent connections */ - le_pimap = register_list_destructors(mail_userlogout_it, NULL); - le_pimapchain = register_list_destructors(NULL, mail_nuke_chain); + le_pimap = register_list_destructors(mail_userlogout_it, NULL, "imap persistent"); + le_pimapchain = register_list_destructors(NULL, mail_nuke_chain, "imap chain persistent"); #endif return SUCCESS; } diff --git a/ext/ingres_ii/ii.c b/ext/ingres_ii/ii.c index 0a37691cf2..d7871f1e07 100644 --- a/ext/ingres_ii/ii.c +++ b/ext/ingres_ii/ii.c @@ -138,11 +138,7 @@ static int _rollback_transaction(II_LINK *link) return 0; } -/* closes the given link, actually disconnecting from server - and releasing associated resources after rolling back the - active transaction (if any) -*/ -static void _close_ii_link(II_LINK *link) +static void close_ii_link(II_LINK *link) { IIAPI_DISCONNPARM disconnParm; IILS_FETCH(); @@ -162,13 +158,25 @@ static void _close_ii_link(II_LINK *link) IIG(num_links)--; } +/* closes the given link, actually disconnecting from server + and releasing associated resources after rolling back the + active transaction (if any) +*/ +static void php_close_ii_link(zend_rsrc_list_entry *rsrc) +{ + II_LINK *link = (II_LINK *)rsrc->ptr; + close_ii_link(link); +} + + /* closes the given persistent link, see _close_ii_link */ -static void _close_ii_plink(II_LINK *link) +static void _close_ii_plink(zend_rsrc_list_entry *rsrc) { + II_LINK *link = (II_LINK *)rsrc->ptr; IILS_FETCH(); - _close_ii_link(link); + close_ii_link(link); IIG(num_persistent)--; } @@ -176,8 +184,9 @@ static void _close_ii_plink(II_LINK *link) used when the request ends to 'refresh' the link for use by the next request */ -static void _clean_ii_plink(II_LINK *link) +static void _clean_ii_plink(zend_rsrc_list_entry *rsrc) { + II_LINK *link = (II_LINK *)rsrc->ptr; IIAPI_AUTOPARM autoParm; IILS_FETCH(); @@ -247,8 +256,8 @@ PHP_MINIT_FUNCTION(ii) REGISTER_INI_ENTRIES(); - le_ii_link = register_list_destructors(_close_ii_link,NULL); - le_ii_plink = register_list_destructors(_clean_ii_plink,_close_ii_plink); + le_ii_link = register_list_destructors(php_close_ii_link,NULL,"ingres"); + le_ii_plink = register_list_destructors(_clean_ii_plink,php_close_ii_plink,"ingres persistent"); IIG(num_persistent) = 0; diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c index c248b012bf..f7dd013f7d 100644 --- a/ext/interbase/interbase.c +++ b/ext/interbase/interbase.c @@ -332,10 +332,16 @@ static void _php_ibase_commit_link(ibase_db_link *link) } /* }}} */ +static void php_ibase_commit_link_rsrc(zend_rsrc_list_entry *rsrc) +{ + ibase_db_link *link = (ibase_db_link *)rsrc->ptr; + _php_ibase_commit_link(link); +} /* {{{ _php_ibase_close_link() */ -static void _php_ibase_close_link(ibase_db_link *link) +static void _php_ibase_close_link(zend_rsrc_list_entry *rsrc) { + ibase_db_link *link = (ibase_db_link *)rsrc->ptr; IBLS_FETCH(); _php_ibase_commit_link(link); @@ -348,8 +354,9 @@ static void _php_ibase_close_link(ibase_db_link *link) /* {{{ _php_ibase_close_plink() */ -static void _php_ibase_close_plink(ibase_db_link *link) +static void _php_ibase_close_plink(zend_rsrc_list_entry *rsrc) { + ibase_db_link *link = (ibase_db_link *)rsrc->ptr; IBLS_FETCH(); _php_ibase_commit_link(link); @@ -363,8 +370,9 @@ static void _php_ibase_close_plink(ibase_db_link *link) /* {{{ _php_ibase_free_result() */ -static void _php_ibase_free_result(ibase_result *ib_result) +static void _php_ibase_free_result(zend_rsrc_list_entry *rsrc) { + ibase_result *ib_result = (ibase_result *)rsrc->ptr; IBLS_FETCH(); IBDEBUG("Freeing result..."); @@ -426,10 +434,16 @@ static void _php_ibase_free_query(ibase_query *ib_query) } /* }}} */ +static void php_ibase_free_query_rsrc(zend_rsrc_list_entry *rsrc) +{ + ibase_query *query = (ibase_auery *)rsrc->ptr; + _php_ibase_free_query(query); +} /* {{{ _php_ibase_free_blob() */ -static void _php_ibase_free_blob(ibase_blob_handle *ib_blob) +static void _php_ibase_free_blob(zend_rsrc_list_entry *rsrc) { + ibase_blob_handle *ib_blob = (ibase_blob_handle *)rsrc->ptr; IBLS_FETCH(); if (ib_blob->bl_handle != NULL) { /* blob open*/ @@ -443,8 +457,9 @@ static void _php_ibase_free_blob(ibase_blob_handle *ib_blob) /* {{{ _php_ibase_free_trans() */ -static void _php_ibase_free_trans(ibase_tr_link *ib_trans) +static void _php_ibase_free_trans(zend_rsrc_list_entry *rsrc) { + ibase_tr_link *ib_trans = (ibase_tr_link *)rsrc->ptr; ibase_db_link *ib_link; IBLS_FETCH(); @@ -494,12 +509,12 @@ PHP_MINIT_FUNCTION(ibase) REGISTER_INI_ENTRIES(); - le_result = register_list_destructors(_php_ibase_free_result, NULL); - le_query = register_list_destructors(_php_ibase_free_query, NULL); - le_blob = register_list_destructors(_php_ibase_free_blob, NULL); - le_link = register_list_destructors(_php_ibase_close_link, NULL); - le_plink = register_list_destructors(_php_ibase_commit_link, _php_ibase_close_plink); - le_trans = register_list_destructors(_php_ibase_free_trans, NULL); + le_result = register_list_destructors(_php_ibase_free_result, NULL, "interbase result"); + le_query = register_list_destructors(php_ibase_free_query_rsrc, NULL, "interbase query"); + le_blob = register_list_destructors(_php_ibase_free_blob, NULL, "interbase blob"); + le_link = register_list_destructors(_php_ibase_close_link, NULL, "interbase link"); + le_plink = register_list_destructors(php_ibase_commit_link_rsrc, _php_ibase_close_plink, "interbase link persistent"); + le_trans = register_list_destructors(_php_ibase_free_trans, NULL, "interbase transaction"); REGISTER_LONG_CONSTANT("IBASE_DEFAULT", PHP_IBASE_DEFAULT, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IBASE_TEXT", PHP_IBASE_TEXT, CONST_PERSISTENT); diff --git a/ext/java/java.c b/ext/java/java.c index 6bb0aaa2d0..1e3065ce17 100644 --- a/ext/java/java.c +++ b/ext/java/java.c @@ -592,7 +592,9 @@ int java_set_property_handler /***************************************************************************/ -static void _php_java_destructor(void *jobject) { +static void _php_java_destructor(zend_rsrc_list_entry *rsrc) +{ + void *jobject = (void *)rsrc->ptr; JG_FETCH(); if (JG(jenv)) (*JG(jenv))->DeleteGlobalRef(JG(jenv), jobject); } @@ -611,7 +613,7 @@ PHP_MINIT_FUNCTION(java) { zend_register_internal_class(&java_class_entry); - le_jobject = register_list_destructors(_php_java_destructor,NULL); + le_jobject = register_list_destructors(_php_java_destructor,NULL,"java"); REGISTER_INI_ENTRIES(); diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 6bf16de8ca..a6ae69b14b 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -118,8 +118,9 @@ ZEND_GET_MODULE(ldap) #endif -static void _close_ldap_link(LDAP *ld) +static void _close_ldap_link(zend_rsrc_list_entry *rsrc) { + LDAP *ld = (LDAP *)rsrc->ptr; LDAPLS_FETCH(); ldap_unbind_s(ld); @@ -128,8 +129,9 @@ static void _close_ldap_link(LDAP *ld) } -static void _free_ldap_result(LDAPMessage *result) +static void _free_ldap_result(zend_rsrc_list_entry *rsrc) { + LDAPMessage *result = (LDAPMessage *)rsrc->ptr; ldap_msgfree(result); } @@ -179,8 +181,8 @@ PHP_MINIT_FUNCTION(ldap) REGISTER_MAIN_LONG_CONSTANT("GSLC_SSL_TWOWAY_AUTH", GSLC_SSL_TWOWAY_AUTH, CONST_PERSISTENT | CONST_CS); #endif - le_result = register_list_destructors(_free_ldap_result, NULL); - le_link = register_list_destructors(_close_ldap_link, NULL); + le_result = register_list_destructors(_free_ldap_result, NULL, "ldap result"); + le_link = register_list_destructors(_close_ldap_link, NULL, "ldap link"); ldap_module_entry.type = type; diff --git a/ext/mcal/php_mcal.c b/ext/mcal/php_mcal.c index 48ce653ebe..a06cdfc67c 100644 --- a/ext/mcal/php_mcal.c +++ b/ext/mcal/php_mcal.c @@ -125,8 +125,9 @@ int le_mcal; char *mcal_user; char *mcal_password; -CALSTREAM *cal_close_it (pils *mcal_le_struct) +CALSTREAM *cal_close_it (zend_rsrc_list_entry *rsrc) { + pils *mcal_le_struct = (pils *)rsrc->ptr; CALSTREAM *ret; ret = cal_close (mcal_le_struct->mcal_stream,0); efree(mcal_le_struct); @@ -151,7 +152,7 @@ PHP_MINFO_FUNCTION(mcal) PHP_MINIT_FUNCTION(mcal) { - le_mcal = register_list_destructors(cal_close_it,NULL); + le_mcal = register_list_destructors(cal_close_it,NULL,"mcal"); REGISTER_MAIN_LONG_CONSTANT("MCAL_SUNDAY",SUNDAY, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_LONG_CONSTANT("MCAL_MONDAY",MONDAY, CONST_PERSISTENT | CONST_CS); diff --git a/ext/msql/php_msql.c b/ext/msql/php_msql.c index e33f08943a..bf2f54771f 100644 --- a/ext/msql/php_msql.c +++ b/ext/msql/php_msql.c @@ -116,9 +116,9 @@ typedef struct { ZEND_FETCH_RESOURCE(msql_query, m_query *, &res, -1, "mSQL result", msql_globals.le_query); \ msql_result = msql_query->result -static void _delete_query(void *arg) +static void _delete_query(zend_rsrc_list_entry *rsrc) { - m_query *query = (m_query *) arg; + m_query *query = (m_query *)rsrc->ptr; if(query->result) msqlFreeResult(query->result); efree(arg); @@ -134,15 +134,17 @@ static m_query *php_msql_query_wrapper(m_result *res, int af_rows) return query; } -static void _close_msql_link(int link) +static void _close_msql_link(zend_rsrc_list_entry *rsrc) { + int link = (int)rsrc->ptr; msqlClose(link); msql_globals.num_links--; } -static void _close_msql_plink(int link) +static void _close_msql_plink(zend_rsrc_list_entry *rsrc) { + int link = (int)rsrc->ptr; msqlClose(link); msql_globals.num_persistent--; msql_globals.num_links--; @@ -160,9 +162,9 @@ DLEXPORT PHP_MINIT_FUNCTION(msql) msql_globals.max_links=-1; } msql_globals.num_persistent=0; - msql_globals.le_query = register_list_destructors(_delete_query,NULL); - msql_globals.le_link = register_list_destructors(_close_msql_link,NULL); - msql_globals.le_plink = register_list_destructors(NULL,_close_msql_plink); + msql_globals.le_query = register_list_destructors(_delete_query,NULL,"msql query"); + msql_globals.le_link = register_list_destructors(_close_msql_link,NULL,"msql link"); + msql_globals.le_plink = register_list_destructors(NULL,_close_msql_plink, "msql link persistent"); msql_module_entry.type = type; diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c index a39237335f..9ae0a28daa 100644 --- a/ext/mssql/php_mssql.c +++ b/ext/mssql/php_mssql.c @@ -133,8 +133,9 @@ static int _clean_invalid_results(list_entry *le) return 0; } -static void _free_mssql_result(mssql_result *result) +static void _free_mssql_result(zend_rsrc_list_entry *rsrc) { + mssql_result *result = (mssql_result *)rsrc->ptr; int i,j; if (result->data) { @@ -168,8 +169,9 @@ static void php_mssql_set_default_link(int id) zend_list_addref(id); } -static void _close_mssql_link(mssql_link *mssql_ptr) +static void _close_mssql_link(zend_rsrc_list_entry *rsrc) { + mssql_link *mssql_ptr = (mssql_link *)rsrc->ptr; MSSQLLS_FETCH(); ELS_FETCH(); @@ -182,8 +184,9 @@ static void _close_mssql_link(mssql_link *mssql_ptr) } -static void _close_mssql_plink(mssql_link *mssql_ptr) +static void _close_mssql_plink(zend_rsrc_list_entry *rsrc) { + mssql_link *mssql_ptr = (mssql_link *)rsrc->ptr; MSSQLLS_FETCH(); dbclose(mssql_ptr->link); @@ -217,9 +220,9 @@ PHP_MINIT_FUNCTION(mssql) #endif REGISTER_INI_ENTRIES(); - le_result = register_list_destructors(_free_mssql_result, NULL); - le_link = register_list_destructors(_close_mssql_link, NULL); - le_plink = register_list_destructors(NULL, _close_mssql_plink); + le_result = register_list_destructors(_free_mssql_result, NULL, "mssql result"); + le_link = register_list_destructors(_close_mssql_link, NULL, "mssql link"); + le_plink = register_list_destructors(NULL, _close_mssql_plink, "mssql link persistent"); mssql_module_entry.type = type; if (dbinit()==FAIL) { diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 8f06268260..c5fc943e62 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -164,8 +164,9 @@ void timeout(int sig); * This wrapper is required since mysql_free_result() returns an integer, and * thus, cannot be used directly */ -static void _free_mysql_result(MYSQL_RES *mysql_result) +static void _free_mysql_result(zend_rsrc_list_entry *rsrc) { + MYSQL_RES *mysql_result = (MYSQL_RES *)rsrc->ptr; mysql_free_result(mysql_result); } @@ -182,8 +183,9 @@ static void php_mysql_set_default_link(int id) } -static void _close_mysql_link(MYSQL *link) +static void _close_mysql_link(zend_rsrc_list_entry *rsrc) { + MYSQL *link = (MYSQL *)rsrc->ptr; void (*handler) (int); MySLS_FETCH(); @@ -194,8 +196,9 @@ static void _close_mysql_link(MYSQL *link) MySG(num_links)--; } -static void _close_mysql_plink(MYSQL *link) +static void _close_mysql_plink(zend_rsrc_list_entry *rsrc) { + MYSQL *link = (MYSQL *)rsrc->ptr; void (*handler) (int); MySLS_FETCH(); @@ -258,9 +261,9 @@ PHP_MINIT_FUNCTION(mysql) ZEND_INIT_MODULE_GLOBALS(mysql, php_mysql_init_globals, NULL); REGISTER_INI_ENTRIES(); - le_result = register_list_destructors(_free_mysql_result,NULL); - le_link = register_list_destructors(_close_mysql_link,NULL); - le_plink = register_list_destructors(NULL,_close_mysql_plink); + le_result = register_list_destructors(_free_mysql_result,NULL,"mysql result"); + le_link = register_list_destructors(_close_mysql_link,NULL, "mysql link"); + le_plink = register_list_destructors(NULL,_close_mysql_plink, "mysql link persistent"); mysql_module_entry.type = type; REGISTER_LONG_CONSTANT("MYSQL_ASSOC", MYSQL_ASSOC, CONST_CS | CONST_PERSISTENT); diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 0e34f4caa7..9b3f8609ed 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -114,10 +114,10 @@ static int oci_ping(oci_server *server); static void oci_debug(const char *format, ...); static void _oci_conn_list_dtor(oci_connection *connection); -static void _oci_stmt_list_dtor(oci_statement *statement); -static void _oci_descriptor_list_dtor(oci_descriptor *descriptor); -static void _oci_server_list_dtor(oci_server *server); -static void _oci_session_list_dtor(oci_session *session); +static void _oci_stmt_list_dtor(zend_rsrc_list_entry *rsrc); +static void _oci_descriptor_list_dtor(zend_rsrc_list_entry *rsrc); +static void _oci_server_list_dtor(zend_rsrc_list_entry *rsrc); +static void _oci_session_list_dtor(zend_rsrc_list_entry *rsrc); static void _oci_column_hash_dtor(void *data); static void _oci_define_hash_dtor(void *data); @@ -361,11 +361,11 @@ PHP_MINIT_FUNCTION(oci) php_oci_init_globals(OCILS_C); #endif - le_stmt = register_list_destructors(_oci_stmt_list_dtor, NULL); - le_conn = register_list_destructors(_oci_conn_list_dtor, NULL); - le_desc = register_list_destructors(_oci_descriptor_list_dtor, NULL); - le_server = register_list_destructors(_oci_server_list_dtor, NULL); - le_session = register_list_destructors(_oci_session_list_dtor, NULL); + le_stmt = register_list_destructors(_oci_stmt_list_dtor, NULL, "oci8 statement"); + le_conn = register_list_destructors(php_oci_free_conn_list, NULL, "oci8 connection"); + le_desc = register_list_destructors(_oci_descriptor_list_dtor, NULL, "oci8 descriptor"); + le_server = register_list_destructors(_oci_server_list_dtor, NULL, "oci8 server"); + le_session = register_list_destructors(_oci_session_list_dtor, NULL, "oci8 session"); INIT_CLASS_ENTRY(oci_lob_class_entry, "OCI-Lob", php_oci_lob_class_functions); @@ -596,8 +596,9 @@ _oci_column_hash_dtor(void *data) /* {{{ _oci_stmt_list_dtor() */ static void -_oci_stmt_list_dtor(oci_statement *statement) +_oci_stmt_list_dtor(zend_rsrc_list_entry *rsrc) { + oci_statement *statement = (oci_statement *)rsrc->ptr; oci_debug("START _oci_stmt_list_dtor: id=%d last_query=\"%s\"",statement->id,SAFE_STRING(statement->last_query)); if (statement->pStmt) { @@ -677,12 +678,20 @@ _oci_conn_list_dtor(oci_connection *connection) } /* }}} */ + +static void php_oci_free_conn_list(zend_rsrc_list_entry *rsrc) +{ + oci_connection *conn = (oci_connection *)rsrc->ptr; + _oci_conn_list_dtor(conn); +} + /* {{{ _oci_descriptor_list_dtor() */ static void -_oci_descriptor_list_dtor(oci_descriptor *descr) +_oci_descriptor_list_dtor(zend_rsrc_list_entry *rsrc) { + oci_descriptor *descr = (oci_descriptor *)rsrc->ptr; oci_debug("START _oci_descriptor_list_dtor: %d",descr->id); zend_list_delete(descr->conn->id); @@ -699,8 +708,9 @@ _oci_descriptor_list_dtor(oci_descriptor *descr) */ static void -_oci_server_list_dtor(oci_server *server) +_oci_server_list_dtor(zend_rsrc_list_entry *rsrc) { + oci_server *server = (oci_server *)rsrc->ptr; if (server->persistent) return; @@ -712,8 +722,9 @@ _oci_server_list_dtor(oci_server *server) */ static void -_oci_session_list_dtor(oci_session *session) +_oci_session_list_dtor(zend_rsrc_list_entry *rsrc) { + oci_session *session = (oci_session *)rsrc->ptr; if (session->persistent) return; diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 05f7cf003d..a3dfa88786 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -137,8 +137,9 @@ ZEND_API php_odbc_globals odbc_globals; ZEND_GET_MODULE(odbc) #endif -static void _free_odbc_result(odbc_result *res) +static void _free_odbc_result(zend_rsrc_list_entry *rsrc) { + odbc_result *res = (odbc_result *)rsrc->ptr; int i; if (res) { @@ -165,8 +166,9 @@ static void _free_odbc_result(odbc_result *res) } } -static void _close_odbc_conn(odbc_connection *conn) +static void _close_odbc_conn(zend_rsrc_list_entry *rsrc) { + odbc_connection *conn = (odbc_connection *)rsrc->ptr; /* FIXME * Closing a connection will fail if there are * pending transactions. It is in the responsibility @@ -181,8 +183,9 @@ static void _close_odbc_conn(odbc_connection *conn) ODBCG(num_links)--; } -static void _close_odbc_pconn(odbc_connection *conn) +static void _close_odbc_pconn(zend_rsrc_list_entry *rsrc) { + odbc_connection *conn = (odbc_connection *)rsrc->ptr; ODBCLS_FETCH(); SQLDisconnect(conn->hdbc); @@ -328,9 +331,9 @@ PHP_MINIT_FUNCTION(odbc) #endif REGISTER_INI_ENTRIES(); - le_result = register_list_destructors(_free_odbc_result, NULL); - le_conn = register_list_destructors(_close_odbc_conn, NULL); - le_pconn = register_list_destructors(NULL, _close_odbc_pconn); + le_result = register_list_destructors(_free_odbc_result, NULL, "odbc result"); + le_conn = register_list_destructors(_close_odbc_conn, NULL, "odbc link"); + le_pconn = register_list_destructors(NULL, _close_odbc_pconn, "odbc link persistent"); odbc_module_entry.type = type; REGISTER_LONG_CONSTANT("ODBC_BINMODE_PASSTHRU", 0, CONST_CS | CONST_PERSISTENT); diff --git a/ext/odbc/velocis.c b/ext/odbc/velocis.c index 03c46d3e33..eaa62164ec 100644 --- a/ext/odbc/velocis.c +++ b/ext/odbc/velocis.c @@ -73,15 +73,17 @@ ZEND_GET_MODULE(velocis) THREAD_LS velocis_module php_velocis_module; THREAD_LS static HENV henv; -static void _close_velocis_link(VConn *conn) +static void _close_velocis_link(zend_rsrc_list_entry *rsrc) { + VConn *conn = (VConn *)rsrc->ptr; if ( conn ) { efree(conn); } } -static void _free_velocis_result(Vresult *res) +static void _free_velocis_result(zend_rsrc_list_entry *rsrc) { + Vresult *res = (Vresult *)rsrc->ptr; if ( res && res->values ) { register int i; for ( i=0; i < res->numcols; i++ ) { @@ -102,8 +104,8 @@ PHP_MINIT_FUNCTION(velocis) php_velocis_module.max_links = -1; } php_velocis_module.num_links = 0; - php_velocis_module.le_link = register_list_destructors(_close_velocis_link,NULL); - php_velocis_module.le_result = register_list_destructors(_free_velocis_result,NULL); + php_velocis_module.le_link = register_list_destructors(_close_velocis_link,NULL,"velocis link"); + php_velocis_module.le_result = register_list_destructors(_free_velocis_result,NULL,"velocis result"); return SUCCESS; } diff --git a/ext/oracle/oracle.c b/ext/oracle/oracle.c index b354b26a80..a0f03b1a73 100644 --- a/ext/oracle/oracle.c +++ b/ext/oracle/oracle.c @@ -65,7 +65,7 @@ PHP_ORA_API php_ora_globals ora_globals; static oraCursor *ora_get_cursor(HashTable *, pval **); static char *ora_error(Cda_Def *); static int ora_describe_define(oraCursor *); -static int _close_oraconn(oraConnection *conn); +static int _close_oraconn(zend_rsrc_list_entry *rsrc); static int _close_oracur(oraCursor *cur); static int _ora_ping(oraConnection *conn); int ora_set_param_values(oraCursor *cursor, int isout); @@ -181,8 +181,9 @@ static const text *ora_func_tab[] = ZEND_GET_MODULE(oracle) #endif -static int _close_oraconn(oraConnection *conn) +static int _close_oraconn(zend_rsrc_list_entry *rsrc) { + oraConnection *conn = (oraConnection *)rsrc->ptr; ORALS_FETCH(); conn->open = 0; @@ -248,6 +249,12 @@ static int _close_oracur(oraCursor *cur) return 1; } +static void php_close_ora_cursor(zend_rsrc_list_entry *rsrc) +{ + oraCursor *cur = (oraCursor *)rsrc->ptr; + _close_oracur(cur); +} + static void php_ora_init_globals(ORALS_D) { if (cfg_get_long("oracle.allow_persistent", @@ -283,9 +290,9 @@ PHP_MINIT_FUNCTION(oracle) php_ora_init_globals(ORALS_C); #endif - le_cursor = register_list_destructors(_close_oracur, NULL); - le_conn = register_list_destructors(_close_oraconn, NULL); - le_pconn = register_list_destructors(NULL, _close_oraconn); + le_cursor = register_list_destructors(php_close_ora_cursor, NULL, "oracle cursor"); + le_conn = register_list_destructors(_close_oraconn, NULL, "oracle link"); + le_pconn = register_list_destructors(NULL, _close_oraconn, "oracle link persistent"); REGISTER_LONG_CONSTANT("ORA_BIND_INOUT", 0, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ORA_BIND_IN", 1, CONST_CS | CONST_PERSISTENT); diff --git a/ext/pdf/pdf.c b/ext/pdf/pdf.c index 3a1758407d..ef5c918af6 100644 --- a/ext/pdf/pdf.c +++ b/ext/pdf/pdf.c @@ -178,18 +178,20 @@ zend_module_entry pdf_module_entry = { ZEND_GET_MODULE(pdf) #endif -static void _free_pdf_image(int image) +static void _free_pdf_image(zend_rsrc_list_entry *rsrc) { } -static void _free_pdf_doc(PDF *pdf) +static void _free_pdf_doc(zend_rsrc_list_entry *rsrc) { + PDF *pdf = (PDF *)rsrc->ptr; PDF_close(pdf); PDF_delete(pdf); } -static void _free_outline(int *outline) +static void _free_outline(zend_rsrc_list_entry *rsrc) { + int *outline = (int *)rsrc->ptr; if(outline) efree(outline); } @@ -235,9 +237,9 @@ static size_t pdf_flushwrite(PDF *p, void *data, size_t size){ PHP_MINIT_FUNCTION(pdf) { - PDF_GLOBAL(le_pdf_image) = register_list_destructors(_free_pdf_image, NULL); - PDF_GLOBAL(le_outline) = register_list_destructors(_free_outline, NULL); - PDF_GLOBAL(le_pdf) = register_list_destructors(_free_pdf_doc, NULL); + PDF_GLOBAL(le_pdf_image) = register_list_destructors(_free_pdf_image, NULL, "pdf image"); + PDF_GLOBAL(le_outline) = register_list_destructors(_free_outline, NULL, "pdf outline"); + PDF_GLOBAL(le_pdf) = register_list_destructors(_free_pdf_doc, NULL, "pdf document"); return SUCCESS; } diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 24deb708be..9e4f9f7312 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -122,8 +122,9 @@ static void php_pgsql_set_default_link(int id) } -static void _close_pgsql_link(PGconn *link) +static void _close_pgsql_link(zend_rsrc_list_entry *rsrc) { + PGconn *link = (PGconn *)rsrc->ptr; PGLS_FETCH(); PQfinish(link); @@ -131,8 +132,9 @@ static void _close_pgsql_link(PGconn *link) } -static void _close_pgsql_plink(PGconn *link) +static void _close_pgsql_plink(zend_rsrc_list_entry *rsrc) { + PGconn *link = (PGconn *)rsrc->ptr; PGLS_FETCH(); PQfinish(link); @@ -141,14 +143,16 @@ static void _close_pgsql_plink(PGconn *link) } -static void _free_ptr(pgLofp *lofp) +static void _free_ptr(zend_rsrc_list_entry *rsrc) { + pgLofp *lofp = (pgLofp *)rsrc->ptr; efree(lofp); } -static void _free_result(pgsql_result_handle *pg_result) +static void _free_result(zend_rsrc_list_entry *rsrc) { + pgsql_result_handle *pg_result = (pgsql_result_handle *)rsrc->ptr; PQclear(pg_result->result); efree(pg_result); } @@ -175,12 +179,12 @@ PHP_MINIT_FUNCTION(pgsql) REGISTER_INI_ENTRIES(); - le_link = register_list_destructors(_close_pgsql_link,NULL); - le_plink = register_list_destructors(NULL,_close_pgsql_plink); + le_link = register_list_destructors(_close_pgsql_link,NULL, "pgsql link"); + le_plink = register_list_destructors(NULL,_close_pgsql_plink, "pgsql link persistent"); /* PGG(le_result = register_list_destructors(PQclear,NULL); */ - le_result = register_list_destructors(_free_result,NULL); - le_lofp = register_list_destructors(_free_ptr,NULL); - le_string = register_list_destructors(_free_ptr,NULL); + le_result = register_list_destructors(_free_result,NULL, "pgsql result"); + le_lofp = register_list_destructors(_free_ptr,NULL, "pgsql large object"); + le_string = register_list_destructors(_free_ptr,NULL, "pgsql string"); REGISTER_LONG_CONSTANT("PGSQL_ASSOC", PGSQL_ASSOC, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PGSQL_NUM", PGSQL_NUM, CONST_CS | CONST_PERSISTENT); diff --git a/ext/pspell/pspell.c b/ext/pspell/pspell.c index cfa848f62c..062697f433 100644 --- a/ext/pspell/pspell.c +++ b/ext/pspell/pspell.c @@ -68,11 +68,15 @@ zend_module_entry pspell_module_entry = { ZEND_GET_MODULE(pspell) #endif -static void php_pspell_close(PspellManager *manager){ +static void php_pspell_close(zend_rsrc_list_entry *rsrc) +{ + PspellManager *manager = (PspellManager *)rsrc->ptr; delete_pspell_manager(manager); } -static void php_pspell_close_config(PspellConfig *config){ +static void php_pspell_close_config(zend_rsrc_list_entry *rsrc) +{ + PspellConfig *config = (PspellConfig *)rsrc->ptr; delete_pspell_config(config); } @@ -81,8 +85,8 @@ PHP_MINIT_FUNCTION(pspell){ REGISTER_MAIN_LONG_CONSTANT("PSPELL_NORMAL", PSPELL_NORMAL, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_LONG_CONSTANT("PSPELL_BAD_SPELLERS", PSPELL_BAD_SPELLERS, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_LONG_CONSTANT("PSPELL_RUN_TOGETHER", PSPELL_RUN_TOGETHER, CONST_PERSISTENT | CONST_CS); - le_pspell = register_list_destructors(php_pspell_close,NULL); - le_pspell_config = register_list_destructors(php_pspell_close_config,NULL); + le_pspell = register_list_destructors(php_pspell_close,NULL,"pspell"); + le_pspell_config = register_list_destructors(php_pspell_close_config,NULL,"pspell config"); return SUCCESS; } diff --git a/ext/rpc/com/COM.c b/ext/rpc/com/COM.c index 782a797904..3fd289f3ee 100644 --- a/ext/rpc/com/COM.c +++ b/ext/rpc/com/COM.c @@ -148,8 +148,9 @@ static char *php_string_from_clsid(CLSID *clsid) } -static void php_idispatch_destructor(IDispatch *i_dispatch) +static void php_idispatch_destructor(zend_rsrc_list_entry *rsrc) { + IDispatch *i_dispatch = (IDispatch *)rsrc->ptr; i_dispatch->lpVtbl->Release(i_dispatch); } @@ -226,7 +227,7 @@ PHP_INI_END() PHP_MINIT_FUNCTION(COM) { CoInitialize(NULL); - le_idispatch = register_list_destructors(php_idispatch_destructor, NULL); + le_idispatch = register_list_destructors(php_idispatch_destructor, NULL,"COM"); php_register_COM_class(); REGISTER_INI_ENTRIES(); return SUCCESS; diff --git a/ext/rpc/java/java.c b/ext/rpc/java/java.c index 6bb0aaa2d0..1e3065ce17 100644 --- a/ext/rpc/java/java.c +++ b/ext/rpc/java/java.c @@ -592,7 +592,9 @@ int java_set_property_handler /***************************************************************************/ -static void _php_java_destructor(void *jobject) { +static void _php_java_destructor(zend_rsrc_list_entry *rsrc) +{ + void *jobject = (void *)rsrc->ptr; JG_FETCH(); if (JG(jenv)) (*JG(jenv))->DeleteGlobalRef(JG(jenv), jobject); } @@ -611,7 +613,7 @@ PHP_MINIT_FUNCTION(java) { zend_register_internal_class(&java_class_entry); - le_jobject = register_list_destructors(_php_java_destructor,NULL); + le_jobject = register_list_destructors(_php_java_destructor,NULL,"java"); REGISTER_INI_ENTRIES(); diff --git a/ext/sablot/sablot.c b/ext/sablot/sablot.c index 44c72adb70..747efaef53 100644 --- a/ext/sablot/sablot.c +++ b/ext/sablot/sablot.c @@ -32,7 +32,7 @@ #include "php_sablot.h" /* Functions related to PHP's list handling */ -static void _php_sablot_free_processor(php_sablot *); +static void _php_sablot_free_processor(zend_rsrc_list_entry *rsrc); /* SAX Handlers */ static void _php_sablot_handler_pair(php_sablot *, zval **, zval **, zval **); @@ -140,7 +140,7 @@ ZEND_GET_MODULE(sablot) PHP_MINIT_FUNCTION(sablot) { SABLOTLS_FETCH(); - SABLOTG(le_sablot) = register_list_destructors(_php_sablot_free_processor, NULL); + SABLOTG(le_sablot) = register_list_destructors(_php_sablot_free_processor, NULL, "sablotron"); return SUCCESS; } @@ -1058,8 +1058,9 @@ static MH_ERROR _php_sablot_error(void *userData, SablotHandle p, MH_ERROR code, /* {{{ _php_sablot_free_processor() Free a Sablot handle */ -static void _php_sablot_free_processor(php_sablot *handle) +static void _php_sablot_free_processor(zend_rsrc_list_entry *rsrc) { + php_sablot *handle = (php_sablot *)rsrc->ptr; if (handle->p) { SablotUnregHandler(handle->p, HLR_MESSAGE, NULL, NULL); SablotUnregHandler(handle->p, HLR_SAX, NULL, NULL); diff --git a/ext/shmop/shmop.c b/ext/shmop/shmop.c index f2531acd18..bbaadb84c0 100644 --- a/ext/shmop/shmop.c +++ b/ext/shmop/shmop.c @@ -60,21 +60,20 @@ zend_module_entry shmop_module_entry = { ZEND_GET_MODULE(shmop) #endif -static void rsclean(struct php_shmop *shmop); +static void rsclean(zend_rsrc_list_entry *rsrc) +{ + struct php_shmop *shmop = (struct php_shmop *)rsrc->ptr; + shmdt(shmop->addr); + efree(shmop); +} PHP_MINIT_FUNCTION(shmop) { - shm_type = register_list_destructors(rsclean, NULL); + shm_type = register_list_destructors(rsclean, NULL, "shmop"); return SUCCESS; } -static void rsclean(struct php_shmop *shmop) -{ - shmdt(shmop->addr); - efree(shmop); -} - PHP_MSHUTDOWN_FUNCTION(shmop) { return SUCCESS; diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 58bfdf9288..b1ea48b029 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -149,17 +149,15 @@ zend_module_entry sockets_module_entry = { ZEND_GET_MODULE(sockets) #endif -static void destroy_fd_sets(fd_set *set); -static void destroy_iovec(php_iovec_t *iov); - - -static void destroy_fd_sets(fd_set *set) +static void destroy_fd_sets(zend_rsrc_list_entry *rsrc) { + fd_set *set = (fd_set *)rsrc->ptr; efree(set); } -static void destroy_iovec(php_iovec_t *iov) +static void destroy_iovec(zend_rsrc_list_entry *rsrc) { + php_iovec_t *iov = (php_iovec_t *)rsrc->ptr; int i; if (iov->count && iov->iov_array) { @@ -175,8 +173,8 @@ static void destroy_iovec(php_iovec_t *iov) PHP_MINIT_FUNCTION(sockets) { SOCKETSLS_FETCH(); - SOCKETSG(le_destroy) = register_list_destructors(destroy_fd_sets, NULL); - SOCKETSG(le_iov) = register_list_destructors(destroy_iovec, NULL); + SOCKETSG(le_destroy) = register_list_destructors(destroy_fd_sets, NULL, "sockets file descriptor set"); + SOCKETSG(le_iov) = register_list_destructors(destroy_iovec, NULL, "sockets i/o vector"); REGISTER_LONG_CONSTANT("AF_UNIX", AF_UNIX, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("AF_INET", AF_INET, CONST_CS | CONST_PERSISTENT); diff --git a/ext/standard/dir.c b/ext/standard/dir.c index ca5694e44a..af3be3b4e5 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -107,8 +107,9 @@ static void php_set_default_dir(int id DIRLS_DC) } -static void _dir_dtor(php_dir *dirp) +static void _dir_dtor(zend_rsrc_list_entry *rsrc) { + php_dir *dirp = (php_dir *)rsrc->ptr; closedir(dirp->dir); efree(dirp); } @@ -125,7 +126,7 @@ PHP_MINIT_FUNCTION(dir) { zend_class_entry dir_class_entry; - le_dirp = register_list_destructors(_dir_dtor,NULL); + le_dirp = register_list_destructors(_dir_dtor,NULL, "dir"); INIT_CLASS_ENTRY(dir_class_entry, "Directory", php_dir_class_functions); dir_class_entry_ptr = zend_register_internal_class(&dir_class_entry); diff --git a/ext/standard/file.c b/ext/standard/file.c index 9d810ca4dc..4d102fd204 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -108,10 +108,6 @@ int file_globals_id; php_file_globals file_globals; #endif -static void _file_fopen_dtor(FILE *pipe); -static void _file_popen_dtor(FILE *pipe); -static void _file_socket_dtor(int *sock); - /* sharing globals is *evil* */ static int le_fopen, le_popen, le_socket; @@ -119,15 +115,17 @@ static int le_fopen, le_popen, le_socket; /* }}} */ /* {{{ Module-Stuff */ -static void _file_popen_dtor(FILE *pipe) +static void _file_popen_dtor(zend_rsrc_list_entry *rsrc) { + FILE *pipe = (FILE *)rsrc->ptr; FIL_FETCH(); FIL(pclose_ret) = pclose(pipe); } -static void _file_socket_dtor(int *sock) +static void _file_socket_dtor(zend_rsrc_list_entry *rsrc) { + int *sock = (int *)rsrc->ptr; SOCK_FCLOSE(*sock); #if HAVE_SHUTDOWN shutdown(*sock, 0); @@ -136,8 +134,9 @@ static void _file_socket_dtor(int *sock) } -static void _file_fopen_dtor(FILE *fp) +static void _file_fopen_dtor(zend_rsrc_list_entry *rsrc) { + FILE *fp = (FILE *)rsrc->ptr; fclose(fp); } @@ -169,9 +168,9 @@ static void php_file_init_globals(php_file_globals *file_globals) PHP_MINIT_FUNCTION(file) { - le_fopen = register_list_destructors(_file_fopen_dtor, NULL); - le_popen = register_list_destructors(_file_popen_dtor, NULL); - le_socket = register_list_destructors(_file_socket_dtor, NULL); + le_fopen = register_list_destructors(_file_fopen_dtor, NULL, "file"); + le_popen = register_list_destructors(_file_popen_dtor, NULL, "pipe"); + le_socket = register_list_destructors(_file_socket_dtor, NULL, "socket"); #ifdef ZTS file_globals_id = ts_allocate_id(sizeof(php_file_globals), (ts_allocate_ctor) php_file_init_globals, NULL); diff --git a/ext/standard/var.c b/ext/standard/var.c index ac0dadc839..c9f7a3601b 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -97,9 +97,9 @@ head_done: PUTS("}\n"); break; case IS_RESOURCE: { - int type; - zend_list_find((*struc)->value.lval, &type); - php_printf("%sresource(%ld) of type %d\n", COMMON, (*struc)->value.lval, type); + char *type_name; + type_name = zend_rsrc_list_get_rsrc_type((*struc)->value.lval); + php_printf("%sresource(%ld) of type (%s)\n", COMMON, (*struc)->value.lval, type_name ? type_name : "Unknown"); break; } default: diff --git a/ext/sybase/php_sybase_db.c b/ext/sybase/php_sybase_db.c index f9f856367d..49aa046597 100644 --- a/ext/sybase/php_sybase_db.c +++ b/ext/sybase/php_sybase_db.c @@ -132,8 +132,9 @@ static int _clean_invalid_results(list_entry *le) } -static void _free_sybase_result(sybase_result *result) +static void _free_sybase_result(zend_rsrc_list_entry *rsrc) { + sybase_result *result = (sybase_result *)rsrc->ptr; int i,j; if (result->data) { @@ -157,8 +158,9 @@ static void _free_sybase_result(sybase_result *result) } -static void _close_sybase_link(sybase_link *sybase_ptr) +static void _close_sybase_link(zend_rsrc_list_entry *rsrc) { + sybase_link *sybase_ptr = (sybase_link *)rsrc->ptr; ELS_FETCH(); sybase_ptr->valid = 0; @@ -177,8 +179,9 @@ static void _close_sybase_link(sybase_link *sybase_ptr) } -static void _close_sybase_plink(sybase_link *sybase_ptr) +static void _close_sybase_plink(zend_rsrc_list_entry *rsrc) { + sybase_link *sybase_ptr = (sybase_link *)rsrc->ptr; dbclose(sybase_ptr->link); dbloginfree(sybase_ptr->login); free(sybase_ptr); @@ -220,9 +223,9 @@ PHP_MINIT_FUNCTION(sybase) } php_sybase_module.num_persistent=0; - php_sybase_module.le_link = register_list_destructors(_close_sybase_link,NULL); - php_sybase_module.le_plink = register_list_destructors(NULL,_close_sybase_plink); - php_sybase_module.le_result = register_list_destructors(_free_sybase_result,NULL); + php_sybase_module.le_link = register_list_destructors(_close_sybase_link,NULL, "sybase-db link"); + php_sybase_module.le_plink = register_list_destructors(NULL,_close_sybase_plink, "sybase-db link persistent"); + php_sybase_module.le_result = register_list_destructors(_free_sybase_result,NULL, "sybase-db result"); return SUCCESS; } diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c index b09fa09377..6c9ff7675f 100644 --- a/ext/sybase_ct/php_sybase_ct.c +++ b/ext/sybase_ct/php_sybase_ct.c @@ -127,9 +127,15 @@ static void _free_sybase_result(sybase_result *result) efree(result); } +static void php_free_sybase_result(zend_rsrc_list_entry *rsrc) +{ + sybase_result *result = (sybase_result *)rsrc->ptr; + _free_sybase_result(result); +} -static void _close_sybase_link(sybase_link *sybase_ptr) +static void _close_sybase_link(zend_rsrc_list_entry *rsrc) { + sybase_link *sybase_ptr = (sybase_link *)rsrc->ptr; CS_INT con_status; ELS_FETCH(); SybCtLS_FETCH(); @@ -160,8 +166,9 @@ static void _close_sybase_link(sybase_link *sybase_ptr) } -static void _close_sybase_plink(sybase_link *sybase_ptr) +static void _close_sybase_plink(zend_rsrc_list_entry *rsrc) { + sybase_link *sybase_ptr = (sybase_link *)rsrc->ptr; CS_INT con_status; SybCtLS_FETCH(); @@ -315,9 +322,9 @@ PHP_MINIT_FUNCTION(sybase) REGISTER_INI_ENTRIES(); - le_link = register_list_destructors(_close_sybase_link,NULL); - le_plink = register_list_destructors(NULL,_close_sybase_plink); - le_result = register_list_destructors(_free_sybase_result,NULL); + le_link = register_list_destructors(_close_sybase_link,NULL, "sybase-ct link"); + le_plink = register_list_destructors(NULL,_close_sybase_plink, "sybase-ct link persistent"); + le_result = register_list_destructors(php_free_sybase_result,NULL, "sybase-ct result"); return SUCCESS; } diff --git a/ext/sysvsem/sysvsem.c b/ext/sysvsem/sysvsem.c index 0b95136ae0..36d33dfd00 100644 --- a/ext/sysvsem/sysvsem.c +++ b/ext/sysvsem/sysvsem.c @@ -87,8 +87,9 @@ THREAD_LS sysvsem_module php_sysvsem_module; #define SYSVSEM_SETVAL 2 -static void release_sysvsem_sem(sysvsem_sem *sem_ptr) +static void release_sysvsem_sem(zend_rsrc_list_entry *rsrc) { + sysvsem_sem *sem_ptr = (sysvsem_sem *)rsrc->ptr; struct sembuf sop[2]; /* Decrement the usage count. */ @@ -116,7 +117,7 @@ static void release_sysvsem_sem(sysvsem_sem *sem_ptr) PHP_MINIT_FUNCTION(sysvsem) { - php_sysvsem_module.le_sem = register_list_destructors(release_sysvsem_sem, NULL); + php_sysvsem_module.le_sem = register_list_destructors(release_sysvsem_sem, NULL, "sysvsem"); return SUCCESS; } diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c index 576fd2c13d..7826411df2 100644 --- a/ext/sysvshm/sysvshm.c +++ b/ext/sysvshm/sysvshm.c @@ -58,15 +58,16 @@ ZEND_GET_MODULE(sysvshm) THREAD_LS sysvshm_module php_sysvshm; -static void php_release_sysvshm(sysvshm_shm *shm_ptr) +static void php_release_sysvshm(zend_rsrc_list_entry *rsrc) { + sysvshm_shm *shm_ptr = (sysvshm_shm *)rsrc->ptr; shmdt((void*)shm_ptr->ptr); efree(shm_ptr); } PHP_MINIT_FUNCTION(sysvshm) { - php_sysvshm.le_shm = register_list_destructors(php_release_sysvshm, NULL); + php_sysvshm.le_shm = register_list_destructors(php_release_sysvshm, NULL, "sysvshm"); if (cfg_get_long("sysvshm.init_mem", &php_sysvshm.init_mem)==FAILURE) { php_sysvshm.init_mem=10000; diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index 0dc03d6bb3..4e5ed606cd 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -223,6 +223,11 @@ static void _php_free_packet_chunk(void *data) } /* }}} */ +static void php_free_wddx_packet(zend_rsrc_list_entry *rsrc) +{ + wddx_packet *packet = (wddx_packet *)rsrc->ptr; + php_wddx_destructor(packet); +} /* {{{ php_wddx_destructor */ void php_wddx_destructor(wddx_packet *packet) @@ -237,7 +242,7 @@ void php_wddx_destructor(wddx_packet *packet) /* {{{ php_minit_wddx */ PHP_MINIT_FUNCTION(wddx) { - le_wddx = register_list_destructors(php_wddx_destructor, NULL); + le_wddx = register_list_destructors(php_free_wddx_packet, NULL, "wddx"); return SUCCESS; } diff --git a/ext/xml/xml.c b/ext/xml/xml.c index a6d10cf77b..55da38a4ed 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -69,7 +69,7 @@ PHP_MSHUTDOWN_FUNCTION(xml); PHP_RSHUTDOWN_FUNCTION(xml); PHP_MINFO_FUNCTION(xml); -static void xml_parser_dtor(xml_parser *); +static void xml_parser_dtor(zend_rsrc_list_entry *rsrc); static void xml_set_handler(zval **, zval **); inline static unsigned short xml_encode_iso_8859_1(unsigned char); inline static char xml_decode_iso_8859_1(unsigned short); @@ -159,7 +159,7 @@ static void php_xml_init_globals(php_xml_globals *xml_globals) PHP_MINIT_FUNCTION(xml) { - le_xml_parser = register_list_destructors(xml_parser_dtor, NULL); + le_xml_parser = register_list_destructors(xml_parser_dtor, NULL, "xml"); #ifdef ZTS xml_globals_id = ts_allocate_id(sizeof(php_xml_globals), (ts_allocate_ctor) php_xml_init_globals, NULL); @@ -276,8 +276,9 @@ static zval *_xml_xmlchar_zval(const XML_Char *s, int len, const XML_Char *encod /* {{{ xml_parser_dtor() */ static void -xml_parser_dtor(xml_parser *parser) +xml_parser_dtor(zend_rsrc_list_entry *rsrc) { + xml_parser *parser = (xml_parser *)rsrc->ptr; if (parser->object) { zval_del_ref(&parser->object); diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 5c34a0ed37..e9e934d120 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -127,7 +127,9 @@ zend_module_entry php_zlib_module_entry = { ZEND_GET_MODULE(php_zlib) #endif -static void phpi_destructor_gzclose(gzFile *zp) { +static void phpi_destructor_gzclose(zend_rsrc_list_entry *rsrc) +{ + gzFile *zp = (gzFile *)rsrc->ptr; (void)gzclose(zp); } @@ -147,7 +149,7 @@ PHP_MINIT_FUNCTION(zlib) #else ZLIBG(gzgetss_state)=0; #endif - le_zp = register_list_destructors(phpi_destructor_gzclose,NULL); + le_zp = register_list_destructors(phpi_destructor_gzclose,NULL,"zlib"); #if HAVE_FOPENCOOKIE |