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

Colomban Wendling lists.ban at xxxxx
Thu Mar 7 19:28:30 UTC 2013


Le 07/03/2013 20:06, Dimitar Zhekov a écrit :
> On Mon, 04 Mar 2013 22:30:40 -0000
> Colomban Wendling <git-noreply at geany.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 ;) )

> Unless we have a policy to always use g_strdup()

We don't, but note that strdup() is not ISO C.

> or there is a real g_/strdup vs. g_/free mismatch
> somewhere, I'm going to revert them.

There was at least 2 mismatches (and actually cppcheck pointed me at the
first one);  but maybe the other were fine.

> Personally I prefer offensive programming: if something goes wrong, let
> it crash and burn, get a proper backtrace and fix it.

Agreed, but so?  AFAIK, strdup() may return NULL upon allocation error;
but g_strdup() won't ever return NULL unless the input string was itself
NULL, since it uses g_malloc() which will abort upon allocation failure.

Regards,
Colomban


More information about the Devel mailing list