Fixed incorrect memory allocation bug with tagcache.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10023 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
62c88c04de
commit
5127cfad1d
2 changed files with 21 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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++)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue