summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2009-06-30 17:39:03 +0000
committerMagnus Holmgren <magnushol@gmail.com>2009-06-30 17:39:03 +0000
commit8c22a60290bb9727a48c2bde94ab38f18c7e847d (patch)
tree9e102c43de4dab705dc9154dbbbfce9b39a55626
parent55b656d9c5be8e96e2e188a5b73d95249b8d77ea (diff)
downloadrockbox-8c22a60290bb9727a48c2bde94ab38f18c7e847d.zip
rockbox-8c22a60290bb9727a48c2bde94ab38f18c7e847d.tar.gz
rockbox-8c22a60290bb9727a48c2bde94ab38f18c7e847d.tar.bz2
rockbox-8c22a60290bb9727a48c2bde94ab38f18c7e847d.tar.xz
Small change to significantly reduce stack usage during database scanning. This should fix FS#10396.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21576 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/tagcache.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index d7a377e..8448c02 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -4091,13 +4091,30 @@ static bool check_deleted_files(void)
return true;
}
+
+/* Note that this function must not be inlined, otherwise the whole point
+ * of having the code in a separate function is lost.
+ */
+static void __attribute__ ((noinline)) check_ignore(const char *dirname,
+ int *ignore, int *unignore)
+{
+ char newpath[MAX_PATH];
+
+ /* check for a database.ignore file */
+ snprintf(newpath, MAX_PATH, "%s/database.ignore", dirname);
+ *ignore = file_exists(newpath);
+ /* check for a database.unignore file */
+ snprintf(newpath, MAX_PATH, "%s/database.unignore", dirname);
+ *unignore = file_exists(newpath);
+}
+
+
static bool check_dir(const char *dirname, int add_files)
{
DIR *dir;
int len;
int success = false;
int ignore, unignore;
- char newpath[MAX_PATH];
dir = opendir(dirname);
if (!dir)
@@ -4106,12 +4123,8 @@ static bool check_dir(const char *dirname, int add_files)
return false;
}
- /* check for a database.ignore file */
- snprintf(newpath, MAX_PATH, "%s/database.ignore", dirname);
- ignore = file_exists(newpath);
- /* check for a database.unignore file */
- snprintf(newpath, MAX_PATH, "%s/database.unignore", dirname);
- unignore = file_exists(newpath);
+ /* check for a database.ignore and database.unignore */
+ check_ignore(dirname, &ignore, &unignore);
/* don't do anything if both ignore and unignore are there */
if (ignore != unignore)