[Geany-Devel] [geany/geany-plugins] 4cc119: Scope: Fix mismatched allocator/deallocator

Dimitar Zhekov dimitar.zhekov at xxxxx
Thu Mar 7 20:41:30 UTC 2013


On Thu, 07 Mar 2013 20:28:30 +0100
Colomban Wendling <lists.ban at herbesfolles.org> wrote:

> >> Log Message:
> >> -----------
> >> Scope: Fix mismatched allocator/deallocator
> > 
> > These are not mismatched, I'm using strdup() instead of strdup() for
> > strings that must never be NULL.
> 
> Huh, what's the difference?  Do strdup() behave differently than
> g_strdup()?  (your sentence quoting the same function twice don't help
> much ;) )

Sorry, I meant "strdup() instead of g_strdup() for strings that must
never be NULL". The difference is that strdup(NULL) crashes.

> > Unless we have a policy to always use g_strdup()...
> 
> We don't, but note that strdup() is not ISO C.

That's a valid argument, though both *NIX and Win~1 have it.

> > ...or there is a real g_/strdup vs. g_/free mismatch somewhere

> For example, an obvious mismatch is
> 
> 	foo ? utils_get_locale_from_utf8(start) : strdup(start)
> 
> utils_get_locale_from_utf8() allocates with glib, strdup() with libc.

Gee. OK, g_strdup() stays. It may be a bit harder to debug these, but
it's not a bug issue, and certainly not worth mismatches.

-- 
E-gards: Jimmy


More information about the Devel mailing list