Re: g_strstrip(" ") segfaulting?



Am Samstag, den 08.05.2010, 19:26 -0300 schrieb Leandro Pereira:
On Sat, May 8, 2010 at 7:18 PM, Daniel Leidert
<daniel leidert spam gmx net> wrote:
Is it the desired behavior, that

g_strstrip(" ")

leads to a segmentation fault? I would expect, that an empty string ("")
or NULL is returned.

The literal " " is a constant -- the operating system might allocate
that to a read-only region. Since g_strstrip() modifies the string
in-place, it isn't surprising that the program segfaults. If the
string you'd like to work with g_strstrip() is a constant, you might
consider using g_strdup() (and g_free() when you're done with it).

Argh. You are right. Thanks!

Regards, Daniel




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