Browse Source

- Simplify by providing delref function

migration/RELEASE_1_0_0
Marcus Boerger 20 years ago
parent
commit
9cd8d73677
  1. 21
      ext/phar/phar.c
  2. 1
      ext/phar/phar_internal.h
  3. 7
      ext/phar/phar_object.c

21
ext/phar/phar.c

@ -106,6 +106,21 @@ void phar_destroy_phar_data(phar_archive_data *data TSRMLS_DC) /* {{{ */
}
/* }}}*/
/**
* Delete refcount and destruct if needed. On destruct return 1 else 0.
*/
int phar_archive_delref(phar_archive_data *phar TSRMLS_DC) /* {{{ */
{
if (--phar->refcount < 0) {
if (zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), phar->fname, phar->fname_len) != SUCCESS) {
phar_destroy_phar_data(phar TSRMLS_CC);
}
return 1;
}
return 0;
}
/* }}}*/
/**
* Destroy phar's in shutdown, here we don't care about aliases
*/
@ -1433,11 +1448,7 @@ static int phar_stream_close(php_stream *stream, int close_handle TSRMLS_DC) /*
/* data->fp is the temporary memory stream containing this file's data */
phar_free_entry_data(data TSRMLS_CC);
if (--phar->refcount < 0) {
if (zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), phar->fname, phar->fname_len) != SUCCESS) {
phar_destroy_phar_data(phar TSRMLS_CC);
}
}
phar_archive_delref(phar TSRMLS_CC);
return 0;
}

1
ext/phar/phar_internal.h

@ -242,6 +242,7 @@ static int phar_dir_stat( php_stream *stream, php_stream_statbuf *ssb TSRMLS_
#endif
int phar_archive_delref(phar_archive_data *phar TSRMLS_DC);
void phar_destroy_phar_data(phar_archive_data *data TSRMLS_DC);
phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len TSRMLS_DC);
void phar_free_entry_data(phar_entry_data *idata TSRMLS_DC);

7
ext/phar/phar_object.c

@ -87,11 +87,8 @@ PHP_METHOD(Phar, canWrite)
*/
static void phar_spl_foreign_dtor(spl_filesystem_object *object TSRMLS_DC) /* {{{ */
{
phar_archive_data *phar_data = (phar_archive_data *) object->oth;
if (--phar_data->refcount < 0) {
phar_destroy_phar_data(phar_data TSRMLS_CC);
}
phar_archive_delref((phar_archive_data *) object->oth TSRMLS_CC);
object->oth = NULL;
}
/* }}} */

Loading…
Cancel
Save