[vlc-devel] [PATCH] DVB-S scanning support

David Kaplan david at 2of1.org
Tue Aug 3 15:22:44 CEST 2010


2010/8/3 Rémi Denis-Courmont <remi at remlab.net>

> On Tue, 3 Aug 2010 13:31:58 +0200, Rémi Duraffort <ivoire at videolan.org>
> wrote:
> >> It would be nice not to care about memory allocation. But I do not see
> >> how that could work. Keep in mind another thread can always change the
> >> variable's value asynchronously.
> > Or we can add a var_Lock("my_var") to get a pointer to the const char
> > without strdup (but that's really dangerous IMHO : too many bad-usages).
>
> As long as we only reference variables by their name rather than by direct
> pointers with reference count, this would require multiple look-up in the
> variables tree. So this would most probably be slower than copying the
> (typically short) strings. On top of that, we would still one line of code
> to 'release' the string anyway (var_Unlock() instead of free()). And we
> could not rely on free(NULL) working properly anymore, which is useful in
> error paths especially. So there is really is no gain.
>
> Also, we would need to replicated the variable API set with unlocked
> functions. The variable lock cannot be recursive, because it is used with a
> condition variable.
>
> As a side note, I have been trying to convert the XML API to return const
> char * values. It's not as simple as I thought. It's always the same issue:
> you need to care how 'long' the string remains valid, which is a non issue
> with strdup().
>

Well it seems that strdup() makes sense actually. I've changed the code to
reflect. :)


-- 
http://blog.2of1.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20100803/82acfd65/attachment.html>


More information about the vlc-devel mailing list