diff options
| author | Miika Pekkarinen <miipekk@ihme.org> | 2006-05-30 18:13:18 +0000 |
|---|---|---|
| committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-05-30 18:13:18 +0000 |
| commit | 5127cfad1d997863fa7e8f490c89293b4d0119e7 (patch) | |
| tree | 556145cff9a1db5ce337ccf3a603c1f1cbd0722e | |
| parent | 62c88c04de7b4794f124987de68e2e5f41975701 (diff) | |
| download | rockbox-5127cfad1d997863fa7e8f490c89293b4d0119e7.zip rockbox-5127cfad1d997863fa7e8f490c89293b4d0119e7.tar.gz rockbox-5127cfad1d997863fa7e8f490c89293b4d0119e7.tar.bz2 rockbox-5127cfad1d997863fa7e8f490c89293b4d0119e7.tar.xz | |
Fixed incorrect memory allocation bug with tagcache.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10023 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/tagcache.c | 19 | ||||
| -rw-r--r-- | firmware/common/dircache.c | 5 |
2 files changed, 21 insertions, 3 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 98beba9..866b5c1 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -1832,6 +1832,10 @@ static bool commit(void) int i, len, rc; int tmpfd; int masterfd; +#ifdef HAVE_DIRCACHE + bool dircache_buffer_stolen = false; +#endif + bool local_allocation = false; logf("committing tagcache"); @@ -1864,12 +1868,18 @@ static bool commit(void) } /* Try to steal every buffer we can :) */ + if (tempbuf_size == 0) + local_allocation = true; + #ifdef HAVE_DIRCACHE if (tempbuf_size == 0) { /* Try to steal the dircache buffer. */ tempbuf = dircache_steal_buffer(&tempbuf_size); tempbuf_size &= ~0x03; + + if (tempbuf_size > 0) + dircache_buffer_stolen = true; } #endif @@ -1956,9 +1966,16 @@ static bool commit(void) logf("tagcache committed"); remove(TAGCACHE_FILE_TEMP); + if (local_allocation) + { + tempbuf = NULL; + tempbuf_size = 0; + } + #ifdef HAVE_DIRCACHE /* Rebuild the dircache, if we stole the buffer. */ - dircache_build(0); + if (dircache_buffer_stolen) + dircache_build(0); #endif #ifdef HAVE_TC_RAMCACHE diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index e5ee77c..e1b592f 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c @@ -37,13 +37,12 @@ #include "kernel.h" #include "usb.h" #include "file.h" +#include "buffer.h" /* Queue commands. */ #define DIRCACHE_BUILD 1 #define DIRCACHE_STOP 2 -extern char *audiobuf; - #define MAX_OPEN_DIRS 8 DIRCACHED opendirs[MAX_OPEN_DIRS]; @@ -668,6 +667,8 @@ void dircache_init(void) { int i; + dircache_initialized = false; + memset(opendirs, 0, sizeof(opendirs)); for (i = 0; i < MAX_OPEN_DIRS; i++) { |