From 7baf84f22bcf68f0c4a14a5ff404119aafe2666a Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 4 Oct 2009 16:30:10 +0200 Subject: Consolidate VFS memory management --- common/vfs_types.h | 10 +++++----- common/vfsutils.c | 28 +++++++++++++++------------- 2 files changed, 20 insertions(+), 18 deletions(-) (limited to 'common') 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); } } -- cgit v1.2.3