Skip to content

Instantly share code, notes, and snippets.

@beberlei
Created June 5, 2020 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beberlei/46caeb70620bcbe912179ce57b57b825 to your computer and use it in GitHub Desktop.
Save beberlei/46caeb70620bcbe912179ce57b57b825 to your computer and use it in GitHub Desktop.
diff --git a/Zend/zend.c b/Zend/zend.c
index a23c134749..5d65fbbc8e 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -1768,13 +1768,9 @@ ZEND_API void zend_map_ptr_extend(size_t last)
}
}
-static void zend_error_notify_callback_dtor(zend_error_notify_callback *callback)
-{
-}
-
int zend_startup_error_notify_callbacks()
{
- zend_llist_init(&zend_error_notify_callbacks, sizeof(zend_error_notify_callback), (void (*)(void *)) zend_error_notify_callback_dtor, 1);
+ zend_llist_init(&zend_error_notify_callbacks, sizeof(zend_error_notify_cb), NULL, 1);
return SUCCESS;
}
@@ -1788,20 +1784,16 @@ int zend_shutdown_error_notify_callbacks()
void zend_register_error_notify_callback(zend_error_notify_cb cb)
{
- zend_error_notify_callback callback;
-
- callback.notify_callback = cb;
-
- zend_llist_add_element(&zend_error_notify_callbacks, &callback);
+ zend_llist_add_element(&zend_error_notify_callbacks, &cb);
}
void zend_error_notify_all_callbacks(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message)
{
zend_llist_element *element;
- zend_error_notify_callback *callback;
+ zend_error_notify_cb callback;
for (element = zend_error_notify_callbacks.head; element; element = element->next) {
- callback = (zend_error_notify_callback*) element->data;
- callback->notify_callback(type, error_filename, error_lineno, message);
+ callback = (zend_error_notify_cb) *(element->data);
+ callback(type, error_filename, error_lineno, message);
}
}
diff --git a/Zend/zend.h b/Zend/zend.h
index 01ac58de25..126ac53a4d 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -354,17 +354,11 @@ ZEND_API void zend_restore_error_handling(zend_error_handling *saved);
typedef void (*zend_error_notify_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message);
BEGIN_EXTERN_C()
-typedef struct {
- zend_error_notify_cb notify_callback;
-} zend_error_notify_callback;
void zend_register_error_notify_callback(zend_error_notify_cb callback);
int zend_startup_error_notify_callbacks();
int zend_shutdown_error_notify_callbacks();
void zend_error_notify_all_callbacks(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message);
-#if ZEND_DEBUG
-void report_zend_debug_error_notify_cb(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message);
-#endif
END_EXTERN_C()
#define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
diff --git a/main/main.c b/main/main.c
index 7691575ff5..888139300f 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1201,7 +1201,7 @@ static void clear_last_error() {
#if ZEND_DEBUG
/* {{{ report_zend_debug_error_notify_cb */
-void report_zend_debug_error_notify_cb(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message)
+static void report_zend_debug_error_notify_cb(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message)
{
if (PG(report_zend_debug)) {
zend_bool trigger_break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment