gphoto2.ds: Use Win32 APIs instead of strdup().

Francois Gouget fgouget at free.fr
Sun May 17 06:30:10 CDT 2009


---

Also added a FIXME noting that we're leaking the gpfile structure (and 
the strdup-ed strings too). Since I don't know how gphoto2 and these .ds 
backends work I have no idea when would be the right time to free them.


 dlls/gphoto2.ds/gphoto2_main.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/dlls/gphoto2.ds/gphoto2_main.c b/dlls/gphoto2.ds/gphoto2_main.c
index bb2c31c..ab4f392 100644
--- a/dlls/gphoto2.ds/gphoto2_main.c
+++ b/dlls/gphoto2.ds/gphoto2_main.c
@@ -37,6 +37,13 @@
 WINE_DEFAULT_DEBUG_CHANNEL(twain);
 
 
+static char* GPHOTO2_StrDup(const char* str)
+{
+    char* dst = HeapAlloc(GetProcessHeap(), 0, strlen(str)+1);
+    strcpy(dst, str);
+    return dst;
+}
+
 static void
 load_filesystem(const char *folder) {
 #ifdef HAVE_GPHOTO2
@@ -63,12 +70,12 @@ load_filesystem(const char *folder) {
 	ret = gp_list_get_name (list, i, &name);
 	if (ret < GP_OK)
 	    continue;
-	gpfile = HeapAlloc(GetProcessHeap(), 0, sizeof(struct gphoto2_file));
+	gpfile = HeapAlloc(GetProcessHeap(), 0, sizeof(struct gphoto2_file)); /* FIXME: Leaked */
 	if (!gpfile)
 	    continue;
 	TRACE("adding %s/%s\n", folder, name);
-	gpfile->folder = strdup(folder);
-	gpfile->filename = strdup(name);
+	gpfile->folder = GPHOTO2_StrDup(folder);
+	gpfile->filename = GPHOTO2_StrDup(name);
 	gpfile->download = FALSE;
 	list_add_tail( &activeDS.files, &gpfile->entry );
     }
-- 
1.6.2.4




More information about the wine-patches mailing list