Hi Mark,

On 28/04/10 5:38 , Mark Brand wrote:
>              const char* user_home = xine_get_homedir();
>              if(user_home)
>              {
> -                char* cfgfile = NULL;
> -                int result = asprintf(&(cfgfile), "%s/.xine/config",
> user_home);
> -                if (result>0) xine_config_load(_xine, cfgfile);
> +                const char* tail = "/.xine/config";
> +                int size = strlen(user_home) + strlen(tail) + 1;
> +                char* cfgfile = malloc(size);
> +                if (cfgfile)
> +                {
> +                    strcpy(cfgfile, user_home);
> +                    strcat(cfgfile, tail);
> +                    xine_config_load(_xine, cfgfile);
> +                }
>              }
> 
>              xine_init(_xine);

Wouldn't it make more sense to use C++ string instead?

Also, is xine_config_load() really taking ownership of the pointer? Or should 
that string
really be free'd after the call?

Code snippets floating around the interweb aren't clear on that - some pass a 
malloc'd
pointer (without freeing it afterwards) but others pass stack data.  From the 
last part
I'd guess we can construct a std::string and pass the c_str() to 
xine_config_load()
without problems.

Cheers,
/ulrich
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to