summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2009-10-04 16:30:10 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2009-10-04 16:30:10 +0200
commit7baf84f22bcf68f0c4a14a5ff404119aafe2666a (patch)
tree260be56a2da98ab48a2cc6d7ddbb36b4adbe3074
parent88ce42250dc9cd1b69eb734b88226a5bd408c4d5 (diff)
downloadtuxcmd-modules-7baf84f22bcf68f0c4a14a5ff404119aafe2666a.tar.xz
Consolidate VFS memory managementv0.6.66
-rw-r--r--common/vfs_types.h10
-rw-r--r--common/vfsutils.c28
-rw-r--r--gvfs/gvfs.c24
-rw-r--r--libarchive/libarchive.c40
-rw-r--r--unrar/unrar.c42
-rw-r--r--zip/zip.cpp40
6 files changed, 94 insertions, 90 deletions
diff --git a/common/vfs_types.h b/common/vfs_types.h
index 658c639..071b666 100644
--- a/common/vfs_types.h
+++ b/common/vfs_types.h
@@ -49,7 +49,7 @@ typedef enum {
} TVFSPasswordSave;
-typedef void (* TVFSLogFunc)(char *s);
+typedef void (* TVFSLogFunc)(const char *s);
typedef void *TVFSFileDes;
@@ -152,10 +152,10 @@ struct TVFSItem {
};
struct TVFSInfo {
- const char *ID; // unique identifier, not shown in GUI
- const char *Name; // plugin name, GUI string (UTF-8)
- const char *About; // GUI string (UTF-8)
- const char *Copyright; // GUI string (UTF-8)
+ char *ID; // unique identifier, not shown in GUI
+ char *Name; // plugin name, GUI string (UTF-8)
+ char *About; // GUI string (UTF-8)
+ char *Copyright; // GUI string (UTF-8)
};
diff --git a/common/vfsutils.c b/common/vfsutils.c
index 71080eb..173c0df 100644
--- a/common/vfsutils.c
+++ b/common/vfsutils.c
@@ -30,28 +30,30 @@
void copy_vfs_item(struct TVFSItem *src, struct TVFSItem *dst)
{
-/*
- dst->ItemType = src->ItemType;
+ dst->FName = g_strdup (src->FName);
+ dst->FDisplayName = g_strdup (src->FDisplayName);
+ dst->iSize = src->iSize;
+ dst->iPackedSize = src->iPackedSize;
+ dst->m_time = src->m_time;
dst->a_time = src->a_time;
dst->c_time = src->c_time;
- dst->iGID = src->iGID;
dst->iMode = src->iMode;
- dst->iSize = src->iSize;
+ dst->sLinkTo = g_strdup (src->sLinkTo);
dst->iUID = src->iUID;
- dst->m_time = src->m_time;
- dst->sFileName = src->sFileName;
- dst->sLinkTo = src->sLinkTo;
- */
- memcpy(dst, src, sizeof(struct TVFSItem));
+ dst->iGID = src->iGID;
+ dst->ItemType = src->ItemType;
}
void free_vfs_item(struct TVFSItem *item)
{
if (item) {
- if (item->FName) free(item->FName);
- if (item->FDisplayName) free(item->FDisplayName);
- if (item->sLinkTo) free(item->sLinkTo);
- free(item);
+ if (item->FName)
+ free(item->FName);
+ if (item->FDisplayName)
+ free(item->FDisplayName);
+ if (item->sLinkTo)
+ free(item->sLinkTo);
+ free(item);
}
}
diff --git a/gvfs/gvfs.c b/gvfs/gvfs.c
index 0e9204a..1fb0230 100644
--- a/gvfs/gvfs.c
+++ b/gvfs/gvfs.c
@@ -339,29 +339,30 @@ VFSVersion ()
return cVFSVersion;
}
-struct TVFSInfo
+struct TVFSInfo *
VFSGetInfo ()
{
- struct TVFSInfo module_info;
+ struct TVFSInfo *module_info = g_malloc0 (sizeof (struct TVFSInfo));
+
+ module_info->ID = g_strdup ("gvfs_plugin");
+ module_info->Name = g_strdup ("GVFS plugin");
+ module_info->About = g_strdup_printf ("version %s, build date: %s", VERSION, BUILD_DATE);
+ module_info->Copyright = g_strdup ("Copyright (C) 2008-2009 Tomáš Bžatek");
- module_info.ID = "gvfs_plugin";
- module_info.Name = "GVFS plugin";
- module_info.About = g_strdup_printf ("version %s, build date: %s", VERSION, BUILD_DATE);
- module_info.Copyright = "Copyright (C) 2008-2009 Tomáš Bžatek";
return module_info;
}
char *
VFSGetExts ()
{
- return "";
+ return NULL;
}
char *
VFSGetServices ()
{
/* FIXME: retrieve list of supported backends from gvfs subsystem */
- return "http;https;ftp;sftp;smb;network";
+ return g_strdup ("http;https;ftp;sftp;smb;network");
}
char *
@@ -463,8 +464,10 @@ VFSGetPath (struct TVFSGlobs *globs)
if (root == NULL)
return NULL;
path = g_file_get_relative_path (root, globs->file);
- if (path == NULL)
+ if (path == NULL) {
+ g_object_unref (root);
return NULL;
+ }
if (! g_path_is_absolute (path))
s = g_strdup_printf ("/%s", path);
else
@@ -481,9 +484,8 @@ VFSGetPath (struct TVFSGlobs *globs)
char *
VFSGetPathURI (struct TVFSGlobs *globs)
{
- if (globs->file) {
+ if (globs->file)
return g_file_get_uri (globs->file);
- }
else
return NULL;
}
diff --git a/libarchive/libarchive.c b/libarchive/libarchive.c
index bb6c1ac..b6dd955 100644
--- a/libarchive/libarchive.c
+++ b/libarchive/libarchive.c
@@ -104,7 +104,7 @@ VFSNew (TVFSLogFunc log_func)
globs->callback_progress = NULL;
globs->log_func = log_func;
- if (globs->log_func != NULL) globs->log_func((char*)"libarchive plugin: VFSInit");
+ if (globs->log_func != NULL) globs->log_func("libarchive plugin: VFSInit");
return globs;
}
@@ -125,7 +125,7 @@ VFSSetCallbacks (struct TVFSGlobs *globs,
void
VFSFree (struct TVFSGlobs *globs)
{
- if (globs->log_func != NULL) globs->log_func((char*)"libarchive plugin: VFSDestroy");
+ if (globs->log_func != NULL) globs->log_func("libarchive plugin: VFSDestroy");
free (globs);
}
@@ -134,30 +134,29 @@ int VFSVersion()
return cVFSVersion;
}
-struct TVFSInfo VFSGetInfo()
+struct TVFSInfo *
+VFSGetInfo()
{
- struct TVFSInfo module_info;
- module_info.ID = "libarchive_plugin";
- module_info.Name = "libarchive plugin";
- char *s = (char*)malloc(255);
- snprintf(s, 255, "version %s, build date: %s\nusing %s\n",
- VERSION, BUILD_DATE, ARCHIVE_LIBRARY_VERSION);
- module_info.About = strdup(s);
- free(s);
- s = (char*)malloc(255);
- snprintf(s, 255, "Plugin Copyright (C) 2008-2009 Tomáš Bžatek\nlibarchive sources Copyright (c) 2003-2007 Tim Kientzle");
- module_info.Copyright = strdup(s);
+ struct TVFSInfo *module_info = g_malloc0 (sizeof (struct TVFSInfo));
+
+ module_info->ID = g_strdup ("libarchive_plugin");
+ module_info->Name = g_strdup ("libarchive plugin");
+ module_info->About = g_strdup_printf ("version %s, build date: %s\nusing %s\n", VERSION, BUILD_DATE, ARCHIVE_LIBRARY_VERSION);
+ module_info->Copyright = g_strdup ("Plugin Copyright (C) 2008-2009 Tomáš Bžatek\nlibarchive sources Copyright (c) 2003-2007 Tim Kientzle");
+
return module_info;
}
-char *VFSGetPrefix(struct TVFSGlobs *globs)
+char *
+VFSGetPrefix (struct TVFSGlobs *globs)
{
- return globs->archive_path;
+ return g_strdup (globs->archive_path);
}
-char *VFSGetExts()
+char *
+VFSGetExts ()
{
- return (char*)"tar;tar.gz;tar.bz2;tgz;tbz2;cpio;iso;a;deb";
+ return g_strdup ("tar;tar.gz;tar.bz2;tgz;tbz2;cpio;iso;a;deb");
}
@@ -302,9 +301,10 @@ TVFSResult VFSClose(struct TVFSGlobs *globs)
return cVFS_OK;
}
-char *VFSGetPath(struct TVFSGlobs *globs)
+char *
+VFSGetPath (struct TVFSGlobs *globs)
{
- return include_trailing_path_sep(globs->curr_dir);
+ return include_trailing_path_sep (globs->curr_dir);
}
u_int64_t VFSGetFileSystemFree(struct TVFSGlobs *globs, char *APath)
diff --git a/unrar/unrar.c b/unrar/unrar.c
index 97d748c..5f34923 100644
--- a/unrar/unrar.c
+++ b/unrar/unrar.c
@@ -120,7 +120,7 @@ VFSNew (TVFSLogFunc log_func)
globs->callback_progress = NULL;
globs->log_func = log_func;
- if (globs->log_func != NULL) globs->log_func((char*)"unrar plugin: VFSInit");
+ if (globs->log_func != NULL) globs->log_func("unrar plugin: VFSInit");
return globs;
}
@@ -141,7 +141,7 @@ VFSSetCallbacks (struct TVFSGlobs *globs,
void
VFSFree (struct TVFSGlobs *globs)
{
- if (globs->log_func != NULL) globs->log_func((char*)"unrar plugin: VFSDestroy");
+ if (globs->log_func != NULL) globs->log_func("unrar plugin: VFSDestroy");
free (globs);
}
@@ -150,31 +150,30 @@ int VFSVersion()
return cVFSVersion;
}
-struct TVFSInfo VFSGetInfo()
+struct TVFSInfo *
+VFSGetInfo()
{
- struct TVFSInfo module_info;
- module_info.ID = "unrar_plugin";
- module_info.Name = "UNRAR plugin";
- char *s = (char*)malloc(255);
- snprintf(s, 255, "version %s, build date: %s\nusing unrar sources v%d.%d [%d-%.2d-%.2d]\n",
- VERSION, BUILD_DATE, RARVER_MAJOR, RARVER_MINOR, RARVER_YEAR, RARVER_MONTH, RARVER_DAY);
- module_info.About = strdup(s);
- free(s);
- s = (char*)malloc(255);
- snprintf(s, 255, "Plugin Copyright (C) 2007-2009 Tomáš Bžatek\nUNRAR sources Copyright (C) 2002-2008 Alexander Roshal");
- module_info.Copyright = strdup(s);
+ struct TVFSInfo *module_info = g_malloc0 (sizeof (struct TVFSInfo));
+
+ module_info->ID = g_strdup ("unrar_plugin");
+ module_info->Name = g_strdup ("UNRAR plugin");
+ module_info->About = g_strdup_printf ("version %s, build date: %s\nusing unrar sources v%d.%d [%d-%.2d-%.2d]\n",
+ VERSION, BUILD_DATE, RARVER_MAJOR, RARVER_MINOR, RARVER_YEAR, RARVER_MONTH, RARVER_DAY);
+ module_info->Copyright = g_strdup ("Plugin Copyright (C) 2007-2009 Tomáš Bžatek\nUNRAR sources Copyright (C) 2002-2008 Alexander Roshal");
+
return module_info;
}
-char *VFSGetPrefix(struct TVFSGlobs *globs)
+char *
+VFSGetPrefix (struct TVFSGlobs *globs)
{
- return globs->archive_path;
-// return (char*)"unrar";
+ return g_strdup (globs->archive_path);
}
-char *VFSGetExts()
+char *
+VFSGetExts ()
{
- return (char*)"rar;r00;r01;r02;r03;r04;r05;r06;r07;r08;r09;r10;r11;r12;r13;r14;r15;r16;r17;r18;r19;r20;r21;r22;r23;r24;r25;r26;r27;r28;r29;r30;r31;r32;r33;r34;r35;r36;r37;r38;r39;r40;r41;r42;r43;r44;r45;r46;r47;r48;r49;r50;r51;r52;r53;r54;r55;r56;r57;r58;r59;r60;r61;r62;r63;r64;r65;r66;r67;r68;r69;r70;r71;r72;r73;r74;r75;r76;r77;r78;r79;r80;r81;r82;r83;r84;r85;r86;r87;r88;r89;r90;r91;r92;r93;r94;r95;r96;r97;r98;r99";
+ return g_strdup ("rar;r00;r01;r02;r03;r04;r05;r06;r07;r08;r09;r10;r11;r12;r13;r14;r15;r16;r17;r18;r19;r20;r21;r22;r23;r24;r25;r26;r27;r28;r29;r30;r31;r32;r33;r34;r35;r36;r37;r38;r39;r40;r41;r42;r43;r44;r45;r46;r47;r48;r49;r50;r51;r52;r53;r54;r55;r56;r57;r58;r59;r60;r61;r62;r63;r64;r65;r66;r67;r68;r69;r70;r71;r72;r73;r74;r75;r76;r77;r78;r79;r80;r81;r82;r83;r84;r85;r86;r87;r88;r89;r90;r91;r92;r93;r94;r95;r96;r97;r98;r99");
}
@@ -454,9 +453,10 @@ TVFSResult VFSClose(struct TVFSGlobs *globs)
return cVFS_OK;
}
-char *VFSGetPath(struct TVFSGlobs *globs)
+char *
+VFSGetPath (struct TVFSGlobs *globs)
{
- return include_trailing_path_sep(globs->curr_dir);
+ return include_trailing_path_sep (globs->curr_dir);
}
u_int64_t VFSGetFileSystemFree(struct TVFSGlobs *globs, char *APath)
diff --git a/zip/zip.cpp b/zip/zip.cpp
index aef7f5f..f848a77 100644
--- a/zip/zip.cpp
+++ b/zip/zip.cpp
@@ -259,7 +259,7 @@ VFSNew (TVFSLogFunc log_func)
globs->callback_progress = NULL;
globs->log_func = log_func;
- if (globs->log_func != NULL) globs->log_func((char*)"zip plugin: VFSInit");
+ if (globs->log_func != NULL) globs->log_func("zip plugin: VFSInit");
return globs;
}
@@ -280,7 +280,7 @@ VFSSetCallbacks (struct TVFSGlobs *globs,
void
VFSFree (struct TVFSGlobs *globs)
{
- if (globs->log_func != NULL) globs->log_func((char*)"zip plugin: VFSDestroy");
+ if (globs->log_func != NULL) globs->log_func("zip plugin: VFSDestroy");
free (globs);
}
@@ -289,30 +289,29 @@ int VFSVersion()
return cVFSVersion;
}
-TVFSInfo VFSGetInfo()
+struct TVFSInfo *
+VFSGetInfo()
{
- TVFSInfo module_info;
- module_info.ID = "zip_plugin";
- module_info.Name = "ZIP plugin";
- char *s = (char*)malloc(255);
- snprintf(s, 255, "version %s, build date: %s\nusing ZipArchive library v%s\n", VERSION, BUILD_DATE, CZipArchive::m_gszVersion);
- module_info.About = strdup(s);
- free(s);
- s = (char*)malloc(255);
- snprintf(s, 255, "Plugin Copyright (C) 2004-2009 Tomáš Bžatek\n%s", CZipArchive::m_gszCopyright);
- module_info.Copyright = strdup(s);
+ struct TVFSInfo *module_info = (TVFSInfo*) g_malloc0 (sizeof (struct TVFSInfo));
+
+ module_info->ID = g_strdup ("zip_plugin");
+ module_info->Name = g_strdup ("ZIP plugin");
+ module_info->About = g_strdup_printf ("version %s, build date: %s\nusing ZipArchive library v%s\n", VERSION, BUILD_DATE, CZipArchive::m_gszVersion);
+ module_info->Copyright = g_strdup_printf ("Plugin Copyright (C) 2004-2009 Tomáš Bžatek\n%s", CZipArchive::m_gszCopyright);
+
return module_info;
}
-char *VFSGetPrefix(struct TVFSGlobs *globs)
+char *
+VFSGetPrefix (struct TVFSGlobs *globs)
{
-// return "zip";
- return globs->archive_path;
+ return g_strdup (globs->archive_path);
}
-char *VFSGetExts()
+char *
+VFSGetExts()
{
- return (char*)"zip";
+ return g_strdup ("zip");
}
@@ -427,9 +426,10 @@ TVFSResult VFSClose(struct TVFSGlobs *globs)
return cVFS_OK;
}
-char *VFSGetPath(struct TVFSGlobs *globs)
+char *
+VFSGetPath (struct TVFSGlobs *globs)
{
- return globs->curr_dir;
+ return g_strdup (globs->curr_dir);
}
u_int64_t VFSGetFileSystemFree(struct TVFSGlobs *globs, char *APath)