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?
Well, I tried to conform to the existing style. In any case, the goal is to construct an appropriate argument for xine_config_load() of type char*. I don't see any reason to use an intermediate type.
Also, is xine_config_load() really taking ownership of the pointer? Or should that string really be free'd after the call?
I don't know. But I didn't change the behavior in this respect. The function asprintf() also allocates a buffer that has to be freed with free(). If this is a memory leak, it's not my creation. I respectfully suggest that the repair of this (possible) defect should be the subject of another patch.
regards, Mark _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
