From ffa186dfc9c223aefb9a6b870fb9d93695fdc782 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 25 Jul 2003 23:17:23 +0000 Subject: [PATCH] Remove the 1024 char limit in the common (non-recursive) case. 2003-07-26 Matthias Clasen * glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive) case. --- ChangeLog | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ ChangeLog.pre-2-12 | 5 +++++ ChangeLog.pre-2-4 | 5 +++++ ChangeLog.pre-2-6 | 5 +++++ ChangeLog.pre-2-8 | 5 +++++ docs/reference/ChangeLog | 4 ++++ docs/reference/glib/tmpl/messages.sgml | 4 ---- glib/gmessages.c | 26 +++++++++++++++++++------- 9 files changed, 53 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93711d1b7..c6e1ce3bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-07-26 Matthias Clasen + + * glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive) + case. + 2003-07-25 Matthias Clasen * glib/gwin32.c: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 93711d1b7..c6e1ce3bb 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +2003-07-26 Matthias Clasen + + * glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive) + case. + 2003-07-25 Matthias Clasen * glib/gwin32.c: diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 93711d1b7..c6e1ce3bb 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,8 @@ +2003-07-26 Matthias Clasen + + * glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive) + case. + 2003-07-25 Matthias Clasen * glib/gwin32.c: diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 93711d1b7..c6e1ce3bb 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +2003-07-26 Matthias Clasen + + * glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive) + case. + 2003-07-25 Matthias Clasen * glib/gwin32.c: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 93711d1b7..c6e1ce3bb 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +2003-07-26 Matthias Clasen + + * glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive) + case. + 2003-07-25 Matthias Clasen * glib/gwin32.c: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 93711d1b7..c6e1ce3bb 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +2003-07-26 Matthias Clasen + + * glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive) + case. + 2003-07-25 Matthias Clasen * glib/gwin32.c: diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 270e9a1ba..bde27d214 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,7 @@ +2003-07-26 Matthias Clasen + + * glib/tmpl/messages.sgml: Remove the note about the message length restriction. + 2003-07-24 Matthias Clasen * glib/tmpl/messages.sgml: Mention the restriction on message length. (#118043, Martyn Russell) diff --git a/docs/reference/glib/tmpl/messages.sgml b/docs/reference/glib/tmpl/messages.sgml index 959edbe42..a8b80efb7 100644 --- a/docs/reference/glib/tmpl/messages.sgml +++ b/docs/reference/glib/tmpl/messages.sgml @@ -9,10 +9,6 @@ versatile support for logging messages with different levels of importance. These functions provide support for logging error messages or messages used for debugging. - -Note that the formatted messages must not exceed 1024 bytes. Longer messages will be truncated. - - There are several built-in levels of messages, defined in #GLogLevelFlags. These can be extended with user-defined levels. diff --git a/glib/gmessages.c b/glib/gmessages.c index c593c8cee..fde63f7f2 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -422,7 +422,6 @@ g_logv (const gchar *log_domain, const gchar *format, va_list args1) { - gchar buffer[1025]; gboolean was_fatal = (log_level & G_LOG_FLAG_FATAL) != 0; gboolean was_recursion = (log_level & G_LOG_FLAG_RECURSION) != 0; gint i; @@ -431,11 +430,6 @@ g_logv (const gchar *log_domain, if (!log_level) return; - /* we use a stack buffer of fixed size, because we might get called - * recursively. - */ - _g_vsnprintf (buffer, 1024, format, args1); - for (i = g_bit_nth_msf (log_level, -1); i >= 0; i = g_bit_nth_msf (log_level, i)) { register GLogLevelFlags test_level; @@ -491,7 +485,25 @@ g_logv (const gchar *log_domain, } } - log_func (log_domain, test_level, buffer, data); + if (test_level & G_LOG_FLAG_RECURSION) + { + /* we use a stack buffer of fixed size, since we're likely + * in an out-of-memory situation + */ + gchar buffer[1025]; + gint size; + size = _g_vsnprintf (buffer, 1024, format, args1); + + log_func (log_domain, test_level, buffer, data); + } + else + { + gchar *msg = g_strdup_vprintf (format, args1); + + log_func (log_domain, test_level, msg, data); + + g_free (msg); + } if (test_level & G_LOG_FLAG_FATAL) {