summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2010-11-07 08:16:49 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2010-11-07 08:16:49 +0000
commit1aa254921a98abec3139e9f3888c82ce2f2188c8 (patch)
tree2a6a8d778c793c84cb79e54b66d0634817d736a8
parent176e2509eb0264d14b473c6e036daa5428b0bac7 (diff)
Further simplify xdelta3-blkcache.h by removing lru_free
-rw-r--r--xdelta3/xdelta3-blkcache.h49
-rw-r--r--xdelta3/xdelta3-main.h6
-rw-r--r--xdelta3/xdelta3-test.h2
3 files changed, 12 insertions, 45 deletions
diff --git a/xdelta3/xdelta3-blkcache.h b/xdelta3/xdelta3-blkcache.h
index 6fbb8dd..87cffac 100644
--- a/xdelta3/xdelta3-blkcache.h
+++ b/xdelta3/xdelta3-blkcache.h
@@ -47,7 +47,6 @@ XD3_MAKELIST(main_blklru_list,main_blklru,link);
47static usize_t lru_size = 0; 47static usize_t lru_size = 0;
48static main_blklru *lru = NULL; /* array of lru_size elts */ 48static main_blklru *lru = NULL; /* array of lru_size elts */
49static main_blklru_list lru_list; 49static main_blklru_list lru_list;
50static main_blklru_list lru_free;
51static int do_src_fifo = 0; /* set to avoid lru */ 50static int do_src_fifo = 0; /* set to avoid lru */
52 51
53static int lru_hits = 0; 52static int lru_hits = 0;
@@ -101,12 +100,12 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
101 100
102 /* LRU-specific */ 101 /* LRU-specific */
103 main_blklru_list_init (& lru_list); 102 main_blklru_list_init (& lru_list);
104 main_blklru_list_init (& lru_free);
105 103
106 if (allow_fake_source) 104 if (allow_fake_source)
107 { 105 {
108 /* TOOLS-specific (e.g., "printdelta"). Note: Check 106 /* TODO: refactor
109 * "allow_fake_source" mode looks broken now. */ 107 * TOOLS/recode-specific: Check "allow_fake_source" mode looks
108 * broken now. */
110 sfile->mode = XO_READ; 109 sfile->mode = XO_READ;
111 sfile->realname = sfile->filename; 110 sfile->realname = sfile->filename;
112 sfile->nread = 0; 111 sfile->nread = 0;
@@ -158,14 +157,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
158 lru_size = 1; 157 lru_size = 1;
159 lru[0].blkno = -1; 158 lru[0].blkno = -1;
160 blksize = option_srcwinsz; 159 blksize = option_srcwinsz;
161 XD3_ASSERT (main_blklru_list_empty (& lru_free)); 160 main_blklru_list_push_back (& lru_list, & lru[0]);
162 XD3_ASSERT (main_blklru_list_empty (& lru_list));
163
164 /* TODO: Refactor. */
165 if (! do_src_fifo)
166 {
167 main_blklru_list_push_back (& lru_free, & lru[0]);
168 }
169 161
170 /* Initialize xd3_source. */ 162 /* Initialize xd3_source. */
171 source->blksize = blksize; 163 source->blksize = blksize;
@@ -182,15 +174,6 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
182 return ret; 174 return ret;
183 } 175 }
184 176
185 /* TODO: Refactor */
186 if (!do_src_fifo)
187 {
188 XD3_ASSERT (!main_blklru_list_empty (& lru_list));
189 main_blklru_list_remove (& lru[0]);
190 }
191 XD3_ASSERT (main_blklru_list_empty (& lru_free));
192 XD3_ASSERT (main_blklru_list_empty (& lru_list));
193
194 source->onblk = lru[0].size; /* xd3 sets onblk */ 177 source->onblk = lru[0].size; /* xd3 sets onblk */
195 178
196 /* If the file is smaller than a block, size is known. */ 179 /* If the file is smaller than a block, size is known. */
@@ -218,6 +201,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
218 lru[i].blk = lru[0].blk + (blksize * i); 201 lru[i].blk = lru[0].blk + (blksize * i);
219 lru[i].blkno = i; 202 lru[i].blkno = i;
220 lru[i].size = blksize; 203 lru[i].size = blksize;
204 main_blklru_list_push_back (& lru_list, & lru[i]);
221 } 205 }
222 } 206 }
223 207
@@ -226,15 +210,6 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
226 /* If the size is not know, we must use FIFO discipline. */ 210 /* If the size is not know, we must use FIFO discipline. */
227 do_src_fifo = 1; 211 do_src_fifo = 1;
228 } 212 }
229 else if (! do_src_fifo)
230 {
231 /* TODO: Refactor.
232 * The encoder forces FIFO, otherwise initialize the LRU data structures */
233 for (i = 0; i < lru_size; ++i)
234 {
235 main_blklru_list_push_back (& lru_list, & lru[i]);
236 }
237 }
238 213
239 /* Call the appropriate set_source method, handle errors, print 214 /* Call the appropriate set_source method, handle errors, print
240 * verbose message, etc. */ 215 * verbose message, etc. */
@@ -343,17 +318,9 @@ main_getblk_lru (xd3_source *source, xoff_t blkno,
343 } 318 }
344 else 319 else
345 { 320 {
346 if (! main_blklru_list_empty (& lru_free)) 321 XD3_ASSERT (! main_blklru_list_empty (& lru_list));
347 { 322 blru = main_blklru_list_pop_front (& lru_list);
348 blru = main_blklru_list_pop_front (& lru_free); 323 main_blklru_list_push_back (& lru_list, blru);
349 main_blklru_list_push_back (& lru_list, blru);
350 }
351 else
352 {
353 XD3_ASSERT (! main_blklru_list_empty (& lru_list));
354 blru = main_blklru_list_pop_front (& lru_list);
355 main_blklru_list_push_back (& lru_list, blru);
356 }
357 } 324 }
358 325
359 lru_filled += 1; 326 lru_filled += 1;
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index 62018e0..d52dfc1 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -261,8 +261,8 @@ struct _main_merge
261 261
262XD3_MAKELIST(main_merge_list,main_merge,link); 262XD3_MAKELIST(main_merge_list,main_merge,link);
263 263
264// TODO: really need to put options in a struct so that internal 264/* TODO: really need to put options in a struct so that internal
265// callers can easily reset state. 265 * callers can easily reset state. */
266 266
267#define DEFAULT_VERBOSE 0 267#define DEFAULT_VERBOSE 0
268 268
@@ -311,7 +311,7 @@ static uint8_t* appheader_used = NULL;
311static uint8_t* main_bdata = NULL; 311static uint8_t* main_bdata = NULL;
312static usize_t main_bsize = 0; 312static usize_t main_bsize = 0;
313 313
314/* Hacks for VCDIFF tools */ 314/* Hacks for VCDIFF tools, recode command. */
315static int allow_fake_source = 0; 315static int allow_fake_source = 0;
316 316
317/* recode_stream is used by both recode/merge for reading vcdiff inputs */ 317/* recode_stream is used by both recode/merge for reading vcdiff inputs */
diff --git a/xdelta3/xdelta3-test.h b/xdelta3/xdelta3-test.h
index d3241de..68499b1 100644
--- a/xdelta3/xdelta3-test.h
+++ b/xdelta3/xdelta3-test.h
@@ -2180,7 +2180,7 @@ test_source_decompression (xd3_stream *stream, int ignore)
2180 2180
2181 /* Now the two identical files are compressed. Delta-encode the target, 2181 /* Now the two identical files are compressed. Delta-encode the target,
2182 * with decompression. */ 2182 * with decompression. */
2183 sprintf (buf, "%s -e -A -vfq -s%s %s %s", program_name, TEST_SOURCE_FILE, 2183 sprintf (buf, "%s -e -vfq -s%s %s %s", program_name, TEST_SOURCE_FILE,
2184 TEST_TARGET_FILE, TEST_DELTA_FILE); 2184 TEST_TARGET_FILE, TEST_DELTA_FILE);
2185 if ((ret = do_cmd (stream, buf))) { return ret; } 2185 if ((ret = do_cmd (stream, buf))) { return ret; }
2186 2186