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 /apps | |
parent | 62c88c04de7b4794f124987de68e2e5f41975701 (diff) | |
download | rockbox-5127cfad1d997863fa7e8f490c89293b4d0119e7.tar.gz rockbox-5127cfad1d997863fa7e8f490c89293b4d0119e7.zip |
Fixed incorrect memory allocation bug with tagcache.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10023 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tagcache.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 98beba9b58..866b5c1444 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -1832,6 +1832,10 @@ static bool commit(void) | |||
1832 | int i, len, rc; | 1832 | int i, len, rc; |
1833 | int tmpfd; | 1833 | int tmpfd; |
1834 | int masterfd; | 1834 | int masterfd; |
1835 | #ifdef HAVE_DIRCACHE | ||
1836 | bool dircache_buffer_stolen = false; | ||
1837 | #endif | ||
1838 | bool local_allocation = false; | ||
1835 | 1839 | ||
1836 | logf("committing tagcache"); | 1840 | logf("committing tagcache"); |
1837 | 1841 | ||
@@ -1864,12 +1868,18 @@ static bool commit(void) | |||
1864 | } | 1868 | } |
1865 | 1869 | ||
1866 | /* Try to steal every buffer we can :) */ | 1870 | /* Try to steal every buffer we can :) */ |
1871 | if (tempbuf_size == 0) | ||
1872 | local_allocation = true; | ||
1873 | |||
1867 | #ifdef HAVE_DIRCACHE | 1874 | #ifdef HAVE_DIRCACHE |
1868 | if (tempbuf_size == 0) | 1875 | if (tempbuf_size == 0) |
1869 | { | 1876 | { |
1870 | /* Try to steal the dircache buffer. */ | 1877 | /* Try to steal the dircache buffer. */ |
1871 | tempbuf = dircache_steal_buffer(&tempbuf_size); | 1878 | tempbuf = dircache_steal_buffer(&tempbuf_size); |
1872 | tempbuf_size &= ~0x03; | 1879 | tempbuf_size &= ~0x03; |
1880 | |||
1881 | if (tempbuf_size > 0) | ||
1882 | dircache_buffer_stolen = true; | ||
1873 | } | 1883 | } |
1874 | #endif | 1884 | #endif |
1875 | 1885 | ||
@@ -1956,9 +1966,16 @@ static bool commit(void) | |||
1956 | logf("tagcache committed"); | 1966 | logf("tagcache committed"); |
1957 | remove(TAGCACHE_FILE_TEMP); | 1967 | remove(TAGCACHE_FILE_TEMP); |
1958 | 1968 | ||
1969 | if (local_allocation) | ||
1970 | { | ||
1971 | tempbuf = NULL; | ||
1972 | tempbuf_size = 0; | ||
1973 | } | ||
1974 | |||
1959 | #ifdef HAVE_DIRCACHE | 1975 | #ifdef HAVE_DIRCACHE |
1960 | /* Rebuild the dircache, if we stole the buffer. */ | 1976 | /* Rebuild the dircache, if we stole the buffer. */ |
1961 | dircache_build(0); | 1977 | if (dircache_buffer_stolen) |
1978 | dircache_build(0); | ||
1962 | #endif | 1979 | #endif |
1963 | 1980 | ||
1964 | #ifdef HAVE_TC_RAMCACHE | 1981 | #ifdef HAVE_TC_RAMCACHE |