glib 1.2, glib docs, and glib 2.0
- From: Jeffrey Stedfast <fejj helixcode com>
- To: gnome-list gnome org
- Cc: gnome-hackers gnome org
- Subject: glib 1.2, glib docs, and glib 2.0
- Date: 01 Dec 2000 00:54:37 +0500
I ran into some confusion the other day with g_basename and g_dirname.
When I g_free()'d the value returned by g_basename(), I'd encounter a
segfault.
Since I didn't have the glib sources on my system and being lazy and not
wanting to look thru them, I took at look at the docs on gtk.org. Now,
it's not clear in the docs whether or not I'm responsible for freeing
the return value of g_basename but it clearly says that I need to free
the return value of g_dirname. Now, seeing as how both returned a gchar
* and my assumption that since the functions were related, I figured
that I'd be responsible for freeing the result of g_basename. I was
wrong.
I'm not sure whether or not this is a solved problem in glib 2.0, so let
me complain (hopefully I'm wasting my breath).
It'd be great if g_basename() returned a const gchar *. Not only does
this serve as a great way to see whether or not I'm responsible for
freeing the return value (makes a great way to double check your
assumptions when reading the docs or function prototypes) but also would
help catch stupid mistakes as gcc will complain if you try and assign a
const pointer to a non-const, etc.
g_basename is only an example, there are numerous functions that behave
similarly in glib (and maybe throughout gtk/gnome/etc).
I'd be willing to spend some of my available free time applying the
necessary changes to glib cvs if it's needed. I'm guessing that this
might take a while as glib seems to have grown quite a lot since 1.2,
but I think the change would be well worth the effort (assuming this
isn't a solved problem).
Jeff
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]