[vlc-devel] Re: Am i going mad??

Kenneth Østby kenneth.ostby at gmail.com
Fri Apr 20 11:24:22 CEST 2007


Hi,

On 4/20/07, Nikos Antonopoulos <nantonop at orbitech.gr> wrote:
>
>
> static void DupString( vlc_value_t *p_val ) { p_val->psz_string =
> strdup( p_val->psz_string ); }
>
>
> surely this is nothing but a small memleak... or is it???



 Well, without knowing its specific function, it doesn't have to memleak.

Consider the following bit of code:

char *f = "hello world";
p_val->psz_string = f;

DupString(p_val);

free(f);
f = NULL;

It can be quite useful at times if you don't want to :
p_val->psz_string = strdup(f);


Kenneth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20070420/50b5e401/attachment.html>


More information about the vlc-devel mailing list