Skip to content

Commit 9084907

Browse files
committed
main/streams: Add a helper macro to retrieve default context
1 parent 5544a77 commit 9084907

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

main/streams/php_stream_context.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ typedef void (*php_stream_notification_func)(php_stream_context *context,
2525

2626
#define PHP_STREAM_NOTIFIER_PROGRESS 1
2727

28+
/* TODO: Remove dependence on ext/standard/file.h for the default context global */
29+
#define php_stream_context_get_default(without_context) \
30+
(without_context) ? NULL : FG(default_context) ? FG(default_context) : \
31+
(FG(default_context) = php_stream_context_alloc())
32+
2833
/* Attempt to fetch context from the zval passed,
2934
If no context was passed, use the default context
3035
The default context has not yet been created, do it now. */
3136
#define php_stream_context_from_zval(zcontext, nocontext) ( \
3237
(zcontext) ? zend_fetch_resource_ex(zcontext, "Stream-Context", php_le_stream_context()) : \
33-
(nocontext) ? NULL : \
34-
FG(default_context) ? FG(default_context) : \
35-
(FG(default_context) = php_stream_context_alloc()) )
38+
php_stream_context_get_default(nocontext))
3639

3740
#define php_stream_context_to_zval(context, zval) { ZVAL_RES(zval, (context)->res); GC_ADDREF((context)->res); }
3841

0 commit comments

Comments
 (0)