BG(user_filter_map) = NULL;
}
- /* cleanup any default context that was created */
- if (FG(default_context)) {
- php_stream_context_free(FG(default_context));
- }
-
return SUCCESS;
}
static ZEND_RSRC_DTOR_FUNC(file_context_dtor)
{
- php_stream_context_free((php_stream_context*)rsrc->ptr);
+ php_stream_context *context = (php_stream_context*)rsrc->ptr;
+ zval_dtor(context->options);
+ php_stream_context_free(context);
}
static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC)
parse_context_options(context, params);
}
- ZEND_REGISTER_RESOURCE(return_value, context, php_le_stream_context());
+ php_stream_context_to_zval(context, return_value);
}
/* }}} */
FG(default_context) ? FG(default_context) : \
(FG(default_context) = php_stream_context_alloc()) )
+#define php_stream_context_to_zval(context, zval) { ZVAL_RESOURCE(zval, (context)->rsrc_id); }
+
typedef struct _php_stream_notifier {
php_stream_notification_func func;
void *ptr;
struct _php_stream_context {
php_stream_notifier *notifier;
zval *options; /* hash keyed by wrapper family or specific wrapper */
+ int rsrc_id; /* used for auto-cleanup */
};
PHPAPI void php_stream_context_free(php_stream_context *context);
MAKE_STD_ZVAL(context->options);
array_init(context->options);
+ context->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, context, php_le_stream_context());
return context;
}