summaryrefslogtreecommitdiff
path: root/firmware/common/dircache.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-06-20 20:12:15 +0000
committerThomas Martitz <kugel@rockbox.org>2011-06-20 20:12:15 +0000
commite0637255341a165e1e186e6f2836c614f0121c8b (patch)
tree248fb995e73cfb4b623a5d041e3e28b311fbafde /firmware/common/dircache.c
parent38da400e58b78f0fd399bdb8e52e1ba63aca75a7 (diff)
downloadrockbox-e0637255341a165e1e186e6f2836c614f0121c8b.tar.gz
rockbox-e0637255341a165e1e186e6f2836c614f0121c8b.zip
Dircache: Return the size of the result string in dircache_copy_path() so that callers don't need to call strlen on it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30034 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common/dircache.c')
-rw-r--r--firmware/common/dircache.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index dc662bb9cd..3eae85ee3b 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -932,16 +932,19 @@ static size_t copy_path_helper(const struct dircache_entry *entry, char *buf, si
932/** 932/**
933 * Function to copy the full absolute path from dircache to the given buffer 933 * Function to copy the full absolute path from dircache to the given buffer
934 * using the given dircache_entry pointer. 934 * using the given dircache_entry pointer.
935 *
936 * Returns the size of the resulting string, or 0 if an error occured
935 */ 937 */
936void dircache_copy_path(const struct dircache_entry *entry, char *buf, int size) 938size_t dircache_copy_path(const struct dircache_entry *entry, char *buf, size_t size)
937{ 939{
938 if (size <= 0 || !buf) 940 if (!size || !buf)
939 return ; 941 return 0;
940 942
941 buf[0] = '/'; 943 buf[0] = '/';
942 size_t res = copy_path_helper(entry, buf, size); 944 size_t res = copy_path_helper(entry, buf, size);
943 /* fixup trailing '/' */ 945 /* fixup trailing '/' */
944 buf[res] = '\0'; 946 buf[res] = '\0';
947 return res;
945} 948}
946 949
947/* --- Directory cache live updating functions --- */ 950/* --- Directory cache live updating functions --- */