Re: Bug in g_message() with long lines ?
- From: Tim Janik <timj gtk org>
- To: Owen Taylor <otaylor redhat com>
- cc: Gtk+ Developers <gtk-devel-list redhat com>
- Subject: Re: Bug in g_message() with long lines ?
- Date: Thu, 27 Apr 2000 10:03:45 +0200 (CEST)
On 26 Apr 2000, Owen Taylor wrote:
>
> Guy Slater <guy@ebi.ac.uk> writes:
>
> > Hi,
> >
> > I'm just starting to use glib (nice library - I wish I'd known
> > about it a long time ago).
> >
> > I think there may be a bug in glib when g_message() is used
> > to report long strings. (Strings here are often DNA,
> > so can be very long).
> >
> > This one had me puzzled for a while as I was using g_message()
> > to print debugging info. The problem also seems to be a bit platform
> > specific.
>
> Well, what you are basically discovering is that the g_log()
> functions are limited to a fixed size buffer. The reason for
> this is that they may be called in out-of-memory situations,
> so can't rely on allocating memory.
>
> I think this probably could be addressed in a couple of ways:
>
> 1) Allow memory to be allocated for non-fatal messages, and
> only use fixed size buffers for fatal messages.
right.
> 2) Try allocating the necessary memory with malloc(), and
> only if that fails fall back to the static buffer.
yeah, as soon as we got g_try_malloc().
> (Printing out long DNA sequences in user messages seems a little
> odd to me, so I'll mention that g_print(), g_message(), etc,
> really aren't meant as replacements for printf() - they are
> just meant for redirectable logging of errors and warnings.)
i second that, except for g_print() which is in fact a printf() replacement.
it doesn't go through g_logv() and can handle very long strings just fine.
>
> Regards,
> Owen
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]