summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-08-15 15:13:17 +0000
committerThomas Martitz <kugel@rockbox.org>2011-08-15 15:13:17 +0000
commit4087875f1cf2677cc8542d7dd19cc3b4a8d26c2b (patch)
treef2417ea686fa668817ae1a14ea182cf1172917df /firmware
parentbf34cdfacb4546cdc2634dda402f010f2dc34f1c (diff)
Dircache: Fix bug introduced in r30308.
dircache_root wasn't initialized at all and the giving allocated_size passed to buffer_release_buffer() didn't account for alignment padding. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30318 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/dircache.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index d114a6ac62..f42c79d169 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -864,8 +864,9 @@ int dircache_build(int last_size)
* free bytes inbetween */
size_t got_size;
char* buf = buffer_get_buffer(&got_size);
- ALIGN_BUFFER(buf, got_size, sizeof(struct dircache_entry));
- d_names_start = d_names_end = (char*)dircache_root + got_size - 1;
+ dircache_root = (struct dircache_entry*)ALIGN_UP(buf,
+ sizeof(struct dircache_entry));
+ d_names_start = d_names_end = buf + got_size - 1;
dircache_size = 0;
generate_dot_d_names();
@@ -897,8 +898,8 @@ int dircache_build(int last_size)
dot -= offset;
dotdot -= offset;
- /* equivalent to dircache_size + DIRCACHE_RESERVE */
- allocated_size = (d_names_end - (char*)dircache_root);
+ /* equivalent to dircache_size + DIRCACHE_RESERVE + align */
+ allocated_size = (d_names_end - buf);
reserve_used = 0;
buffer_release_buffer(allocated_size);