aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-09-07 20:21:19 +0200
committerMax Kellermann <max@duempel.org>2010-09-07 20:21:19 +0200
commit663815ead8feca5188b9a6e06316421303f06851 (patch)
tree5a4cff877ea0684bcbd3784650bfa93e5e7d7ef2
parentbc87ec0059321485727b13ab7456de9dead2da8b (diff)
downloadmpd-663815ead8feca5188b9a6e06316421303f06851.tar.gz
mpd-663815ead8feca5188b9a6e06316421303f06851.tar.xz
mpd-663815ead8feca5188b9a6e06316421303f06851.zip
playlist_vector: update_or_add() returns bool
False if the vector was not modified.
Diffstat (limited to '')
-rw-r--r--src/playlist_vector.c7
-rw-r--r--src/playlist_vector.h5
2 files changed, 10 insertions, 2 deletions
diff --git a/src/playlist_vector.c b/src/playlist_vector.c
index 80b70a96c..7c1765a98 100644
--- a/src/playlist_vector.c
+++ b/src/playlist_vector.c
@@ -93,16 +93,21 @@ playlist_vector_add(struct playlist_vector *pv,
pv->head = pm;
}
-void
+bool
playlist_vector_update_or_add(struct playlist_vector *pv,
const char *name, time_t mtime)
{
struct playlist_metadata **pmp = playlist_vector_find_p(pv, name);
if (pmp != NULL) {
struct playlist_metadata *pm = *pmp;
+ if (mtime == pm->mtime)
+ return false;
+
pm->mtime = mtime;
} else
playlist_vector_add(pv, name, mtime);
+
+ return true;
}
bool
diff --git a/src/playlist_vector.h b/src/playlist_vector.h
index a2ba306d3..566de5f00 100644
--- a/src/playlist_vector.h
+++ b/src/playlist_vector.h
@@ -58,7 +58,10 @@ void
playlist_vector_add(struct playlist_vector *pv,
const char *name, time_t mtime);
-void
+/**
+ * @return true if the vector or one of its items was modified
+ */
+bool
playlist_vector_update_or_add(struct playlist_vector *pv,
const char *name, time_t mtime);