Re: Bug in g_message() with long lines ?

Tim Janik <> writes:

> > 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().

We don't need to wait for g_try_malloc() - since we control
both the allocation and freeing of that buffer, we can
simply use malloc() and free().

> > (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.

Well, if you don't want to redirect the output of g_print(), there
is no reason to use it. It is slower than printf(), and one
more char to type.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]