Enlightenment CVS committal
Author : englebass
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_file
Modified Files:
ecore_file_download.c
Log Message:
fix memleak (Thanks vinicius).
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_file/ecore_file_download.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ecore_file_download.c 6 Aug 2007 20:00:28 -0000 1.16
+++ ecore_file_download.c 7 Nov 2007 21:15:11 -0000 1.17
@@ -90,7 +90,7 @@
if (!_job_list)
return;
-
+
ecore_list_first_goto(_job_list);
while ((job = ecore_list_next(_job_list)))
{
@@ -116,7 +116,7 @@
*
* You must provide the full url, including 'http://', 'ftp://' or 'file://'.\n
* If @p dst already exist it will not be overwritten and the function will
fail.\n
- * Ecore must be compiled with CURL to download using http and ftp protocols.
+ * Ecore must be compiled with CURL to download using http and ftp protocols.
*/
EAPI int
ecore_file_download(const char *url, const char *dst,
@@ -124,7 +124,14 @@
int (*progress_cb)(void *data, const char *file, long int
dltotal, long int dlnow, long int ultotal, long int ulnow),
void *data)
{
- if (!ecore_file_is_dir(ecore_file_dir_get((char *)dst))) return 0;
+ char *dir = ecore_file_dir_get(dst);
+
+ if (!ecore_file_is_dir(dir))
+ {
+ free(dir);
+ return 0;
+ }
+ free(dir);
if (ecore_file_exists(dst)) return 0;
/* FIXME: Add handlers for http and ftp! */
@@ -145,7 +152,7 @@
{
/* download */
Ecore_File_Download_Job *job;
-
+
job = _ecore_file_download_curl(url, dst, completion_cb, progress_cb,
data);
if (job)
return 1;
@@ -170,7 +177,7 @@
* @return 1 if protocol is handled or 0 if not
*
* @p protocol can be 'http://', 'ftp://' or 'file://'.\n
- * Ecore must be compiled with CURL to handle http and ftp protocols.
+ * Ecore must be compiled with CURL to handle http and ftp protocols.
*/
EAPI int
ecore_file_download_protocol_available(const char *protocol)
@@ -185,15 +192,15 @@
}
#ifdef HAVE_CURL
-/* this reports the downloads progress. if we return 0, then download
+/* this reports the downloads progress. if we return 0, then download
* continues, if we return anything else, then the download stops */
static int
_ecore_file_download_curl_progress_func(void *clientp, double dltotal, double
dlnow, double ultotal, double ulnow)
-{
+{
Ecore_File_Download_Job *job;
-
+
job = clientp;
-
+
if(job->progress_cb)
return job->progress_cb(job->data, job->dst, (long int)dltotal, (long
int)dlnow, (long int)ultotal, (long int)ulnow);
return 0;
@@ -203,9 +210,9 @@
_ecore_file_download_curl(const char *url, const char *dst,
void (*completion_cb)(void *data, const char *file,
int status),
- int (*progress_cb)(void *data, const char *file,
+ int (*progress_cb)(void *data, const char *file,
long int dltotal, long int dlnow,
- long int ultotal,
+ long int ultotal,
long int ulnow),
void *data)
{
@@ -234,17 +241,17 @@
free(job);
return NULL;
}
-
+
curl_easy_setopt(job->curl, CURLOPT_URL, url);
curl_easy_setopt(job->curl, CURLOPT_WRITEDATA, job->file);
-
+
if (progress_cb)
{
- curl_easy_setopt(job->curl, CURLOPT_NOPROGRESS, FALSE);
- curl_easy_setopt(job->curl, CURLOPT_PROGRESSDATA, job);
+ curl_easy_setopt(job->curl, CURLOPT_NOPROGRESS, FALSE);
+ curl_easy_setopt(job->curl, CURLOPT_PROGRESSDATA, job);
curl_easy_setopt(job->curl, CURLOPT_PROGRESSFUNCTION,
_ecore_file_download_curl_progress_func);
}
-
+
job->data = data;
job->completion_cb = completion_cb;
job->progress_cb = progress_cb;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs