gpsd-dev
[Top][All Lists]
Advanced

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

Re: [gpsd-dev] [PATCH 2/2] hacking: mention strdup in the no-malloc sect


From: Paul Fertser
Subject: Re: [gpsd-dev] [PATCH 2/2] hacking: mention strdup in the no-malloc section.
Date: Mon, 28 Mar 2016 14:01:01 +0300
User-agent: Mutt/1.5.23 (2014-03-12)

On Mon, Mar 28, 2016 at 12:18:58PM +0200, Beat Bolli wrote:
>  <p>Don't undo this by using malloc/free in a driver or anywhere else.</p>
>  
> +<p>Please note that this restriction includes indirect callers of malloc
> +like strdup.</p>
> +

Strictly speaking, there's plenty of indirect malloc callers that are
already used in gpsd. Early in the init sequence getservbyname() is
called and it does malloc() under the hood. printf() implementations
can also do that unpredicatbly, etc etc.

One can say that the restriction applies to such library functions
that require explicit free(). But what about
initialize_dbus_connection()? It certainly does malloc() early on gpsd
startup via dbus_bus_get(), and doesn't require explicit free().

So the problem is not in the malloc/free but in the resource
management in general. In C++ world you'd just require everybody to
follow RAII. In the C world just prohibiting malloc/free is certainly
not enough to tackle this, IMHO.

-- 
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]