summaryrefslogtreecommitdiff
path: root/apps/tagcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r--apps/tagcache.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index e60732fb65..170a066a36 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -102,9 +102,6 @@
102 */ 102 */
103#define TAGCACHE_SUPPORT_FOREIGN_ENDIAN 103#define TAGCACHE_SUPPORT_FOREIGN_ENDIAN
104 104
105/* Maximum length of a single tag. */
106#define TAG_MAXLEN (MAX_PATH*2)
107
108/* Allow a little drift to the filename ordering (should not be too high/low). */ 105/* Allow a little drift to the filename ordering (should not be too high/low). */
109#define POS_HISTORY_COUNT 4 106#define POS_HISTORY_COUNT 4
110 107
@@ -169,9 +166,6 @@ static struct event_queue tagcache_queue SHAREDBSS_ATTR;
169static long tagcache_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)]; 166static long tagcache_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)];
170static const char tagcache_thread_name[] = "tagcache"; 167static const char tagcache_thread_name[] = "tagcache";
171#endif 168#endif
172/* buffer size for all the (stack allocated & static) buffers handling tc data */
173#define TAGCACHE_BUFSZ (TAG_MAXLEN+32)
174
175 169
176/* Previous path when scanning directory tree recursively. */ 170/* Previous path when scanning directory tree recursively. */
177static char curpath[TAGCACHE_BUFSZ]; 171static char curpath[TAGCACHE_BUFSZ];
@@ -1849,11 +1843,8 @@ bool tagcache_search_add_clause(struct tagcache_search *tcs,
1849 return true; 1843 return true;
1850} 1844}
1851 1845
1852static bool get_next(struct tagcache_search *tcs, bool is_numeric) 1846static bool get_next(struct tagcache_search *tcs, bool is_numeric, char *buf, long bufsz)
1853{ 1847{
1854 /* WARNING pointers into buf are used in outside functions */
1855 static char buf[TAGCACHE_BUFSZ];
1856 const int bufsz = sizeof(buf);
1857 struct tagfile_entry entry; 1848 struct tagfile_entry entry;
1858#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) 1849#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
1859 long flag = 0; 1850 long flag = 0;
@@ -2001,12 +1992,12 @@ static bool get_next(struct tagcache_search *tcs, bool is_numeric)
2001 return true; 1992 return true;
2002} 1993}
2003 1994
2004bool tagcache_get_next(struct tagcache_search *tcs) 1995bool tagcache_get_next(struct tagcache_search *tcs, char *buf, long size)
2005{ 1996{
2006 if (tcs->valid && tagcache_is_usable()) 1997 if (tcs->valid && tagcache_is_usable())
2007 { 1998 {
2008 bool is_numeric = TAGCACHE_IS_NUMERIC(tcs->type); 1999 bool is_numeric = TAGCACHE_IS_NUMERIC(tcs->type);
2009 while (get_next(tcs, is_numeric)) 2000 while (get_next(tcs, is_numeric, buf, size))
2010 { 2001 {
2011 if (tcs->result_len > 1) 2002 if (tcs->result_len > 1)
2012 return true; 2003 return true;
@@ -3971,8 +3962,6 @@ static bool delete_entry(long idx_id)
3971 int tag, i; 3962 int tag, i;
3972 struct index_entry idx, myidx; 3963 struct index_entry idx, myidx;
3973 struct master_header myhdr; 3964 struct master_header myhdr;
3974 char buf[TAGCACHE_BUFSZ];
3975 const int bufsz = sizeof(buf);
3976 int in_use[TAG_COUNT]; 3965 int in_use[TAG_COUNT];
3977 3966
3978 logf("delete_entry(): %ld", idx_id); 3967 logf("delete_entry(): %ld", idx_id);
@@ -4081,7 +4070,8 @@ static bool delete_entry(long idx_id)
4081 /* Skip the header block */ 4070 /* Skip the header block */
4082 lseek(fd, myidx.tag_seek[tag], SEEK_SET); 4071 lseek(fd, myidx.tag_seek[tag], SEEK_SET);
4083 4072
4084 switch (read_tagfile_entry_and_tag(fd, &tfe, buf, bufsz)) 4073 switch (read_tagfile_entry_and_tag(fd, &tfe,
4074 build_idx_buf, build_idx_bufsz))
4085 { 4075 {
4086 case e_SUCCESS_LEN_ZERO: 4076 case e_SUCCESS_LEN_ZERO:
4087 logf("deleted_entry(): SUCCESS"); 4077 logf("deleted_entry(): SUCCESS");
@@ -4099,7 +4089,8 @@ static bool delete_entry(long idx_id)
4099 goto cleanup; 4089 goto cleanup;
4100 } 4090 }
4101 4091
4102 myidx.tag_seek[tag] = crc_32(buf, strlen(buf), 0xffffffff); 4092 myidx.tag_seek[tag] = crc_32(build_idx_buf,
4093 strlen(build_idx_buf), 0xffffffff);
4103 } 4094 }
4104 4095
4105 if (in_use[tag]) 4096 if (in_use[tag])