aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-29 21:11:04 +0100
committerMax Kellermann <max@duempel.org>2013-01-29 21:11:04 +0100
commita42f9fd4e2ccb164c0634571da9903e6a2aa507a (patch)
tree104cd2ac6598f1529f03e18c8f77135998b1a55d
parente66005563efb24cdeb0c034a680f6a5556265c09 (diff)
downloadmpd-a42f9fd4e2ccb164c0634571da9903e6a2aa507a.tar.gz
mpd-a42f9fd4e2ccb164c0634571da9903e6a2aa507a.tar.xz
mpd-a42f9fd4e2ccb164c0634571da9903e6a2aa507a.zip
ArchivePlugin: scan_next() returns const string
-rw-r--r--src/ArchivePlugin.cxx2
-rw-r--r--src/ArchivePlugin.hxx4
-rw-r--r--src/UpdateArchive.cxx12
-rw-r--r--src/archive/Bzip2ArchivePlugin.cxx4
-rw-r--r--src/archive/Iso9660ArchivePlugin.cxx6
-rw-r--r--src/archive/ZzipArchivePlugin.cxx6
6 files changed, 18 insertions, 16 deletions
diff --git a/src/ArchivePlugin.cxx b/src/ArchivePlugin.cxx
index 42c90eec8..55721efc3 100644
--- a/src/ArchivePlugin.cxx
+++ b/src/ArchivePlugin.cxx
@@ -70,7 +70,7 @@ archive_file_scan_reset(struct archive_file *file)
file->plugin->scan_reset(file);
}
-char *
+const char *
archive_file_scan_next(struct archive_file *file)
{
assert(file != NULL);
diff --git a/src/ArchivePlugin.hxx b/src/ArchivePlugin.hxx
index 66ec6d830..448a1941c 100644
--- a/src/ArchivePlugin.hxx
+++ b/src/ArchivePlugin.hxx
@@ -62,7 +62,7 @@ struct archive_plugin {
* (as pathnames) and move read index to next file. When there is no
* next file it return NULL.
*/
- char *(*scan_next)(struct archive_file *);
+ const char *(*scan_next)(struct archive_file *);
/**
* Opens an input_stream of a file within the archive.
@@ -98,7 +98,7 @@ archive_file_close(struct archive_file *file);
void
archive_file_scan_reset(struct archive_file *file);
-char *
+const char *
archive_file_scan_next(struct archive_file *file);
struct input_stream *
diff --git a/src/UpdateArchive.cxx b/src/UpdateArchive.cxx
index 3088e942d..5da212e9d 100644
--- a/src/UpdateArchive.cxx
+++ b/src/UpdateArchive.cxx
@@ -33,17 +33,19 @@
#include <string.h>
static void
-update_archive_tree(Directory *directory, char *name)
+update_archive_tree(Directory *directory, const char *name)
{
- char *tmp = strchr(name, '/');
+ const char *tmp = strchr(name, '/');
if (tmp) {
- *tmp = 0;
+ char *child_name = g_strndup(name, tmp - name);
//add dir is not there already
db_lock();
Directory *subdir =
- directory->MakeChild(name);
+ directory->MakeChild(child_name);
subdir->device = DEVICE_INARCHIVE;
db_unlock();
+ g_free(child_name);
+
//create directories first
update_archive_tree(subdir, tmp+1);
} else {
@@ -122,7 +124,7 @@ update_archive_file2(Directory *parent, const char *name,
archive_file_scan_reset(file);
- char *filepath;
+ const char *filepath;
while ((filepath = archive_file_scan_next(file)) != NULL) {
/* split name into directory and file */
g_debug("adding archive file: %s", filepath);
diff --git a/src/archive/Bzip2ArchivePlugin.cxx b/src/archive/Bzip2ArchivePlugin.cxx
index b344f1186..4b0d5223e 100644
--- a/src/archive/Bzip2ArchivePlugin.cxx
+++ b/src/archive/Bzip2ArchivePlugin.cxx
@@ -158,11 +158,11 @@ bz2_scan_reset(struct archive_file *file)
context->reset = true;
}
-static char *
+static const char *
bz2_scan_next(struct archive_file *file)
{
Bzip2ArchiveFile *context = (Bzip2ArchiveFile *) file;
- char *name = NULL;
+ const char *name = NULL;
if (context->reset) {
name = context->name;
diff --git a/src/archive/Iso9660ArchivePlugin.cxx b/src/archive/Iso9660ArchivePlugin.cxx
index f92895b7d..fe752ff3b 100644
--- a/src/archive/Iso9660ArchivePlugin.cxx
+++ b/src/archive/Iso9660ArchivePlugin.cxx
@@ -141,16 +141,16 @@ iso9660_archive_scan_reset(struct archive_file *file)
context->iter = context->list;
}
-static char *
+static const char *
iso9660_archive_scan_next(struct archive_file *file)
{
Iso9660ArchiveFile *context =
(Iso9660ArchiveFile *)file;
- char *data = NULL;
+ const char *data = NULL;
if (context->iter != NULL) {
///fetch data and goto next
- data = (char *)context->iter->data;
+ data = (const char *)context->iter->data;
context->iter = g_slist_next(context->iter);
}
return data;
diff --git a/src/archive/ZzipArchivePlugin.cxx b/src/archive/ZzipArchivePlugin.cxx
index dabdd41d9..81bf91f07 100644
--- a/src/archive/ZzipArchivePlugin.cxx
+++ b/src/archive/ZzipArchivePlugin.cxx
@@ -109,14 +109,14 @@ zzip_archive_scan_reset(struct archive_file *file)
context->iter = context->list;
}
-static char *
+static const char *
zzip_archive_scan_next(struct archive_file *file)
{
ZzipArchiveFile *context = (ZzipArchiveFile *) file;
- char *data = NULL;
+ const char *data = NULL;
if (context->iter != NULL) {
///fetch data and goto next
- data = (char *)context->iter->data;
+ data = (const char *)context->iter->data;
context->iter = g_slist_next(context->iter);
}
return data;