diff options
author | 7 <NotZed@Ximian.com> | 2001-09-18 08:43:37 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-09-18 08:43:37 +0800 |
commit | 37a637099f6f358751f9d89c60edb4c4bdb7469a (patch) | |
tree | 3166a64b4efb1836ae542f8380885a2f228aec46 /libibex | |
parent | 23cd9574ea2ddc15a7f991b7853b856c25eb2d59 (diff) | |
download | gsoc2013-evolution-37a637099f6f358751f9d89c60edb4c4bdb7469a.tar.gz gsoc2013-evolution-37a637099f6f358751f9d89c60edb4c4bdb7469a.tar.zst gsoc2013-evolution-37a637099f6f358751f9d89c60edb4c4bdb7469a.zip |
Fix the tail space calculation, it didn't always take into account the
2001-09-17 <NotZed@Ximian.com>
* disktail.c (tail_space): Fix the tail space calculation, it
didn't always take into account the space used by a new tail node
(i think).
(tail_info): Add a failback assertion that end >= start. Fix all
callers (needed to add blocks argument).
svn path=/trunk/; revision=12923
Diffstat (limited to 'libibex')
-rw-r--r-- | libibex/ChangeLog | 8 | ||||
-rw-r--r-- | libibex/disktail.c | 19 |
2 files changed, 19 insertions, 8 deletions
diff --git a/libibex/ChangeLog b/libibex/ChangeLog index 16677bbca4..394b2e7aa9 100644 --- a/libibex/ChangeLog +++ b/libibex/ChangeLog @@ -1,3 +1,11 @@ +2001-09-17 <NotZed@Ximian.com> + + * disktail.c (tail_space): Fix the tail space calculation, it + didn't always take into account the space used by a new tail node + (i think). + (tail_info): Add a failback assertion that end >= start. Fix all + callers (needed to add blocks argument). + 2001-08-16 Not Zed <NotZed@Ximian.com> * dumpindex.c (main): Force open of internal data before using it. diff --git a/libibex/disktail.c b/libibex/disktail.c index 50c21afa9c..0117924d4f 100644 --- a/libibex/disktail.c +++ b/libibex/disktail.c @@ -85,7 +85,7 @@ struct _IBEXStoreClass ibex_diskarray_class = { static int -tail_info(struct _tailblock *bucket, nameid_t tailid, blockid_t **startptr) +tail_info(struct _memcache *blocks, struct _tailblock *bucket, nameid_t tailid, blockid_t **startptr) { blockid_t *start, *end; int index; @@ -100,6 +100,9 @@ tail_info(struct _tailblock *bucket, nameid_t tailid, blockid_t **startptr) } if (startptr) *startptr = start; + + ibex_block_cache_assert(blocks, end >= start); + return end-start; } @@ -194,7 +197,7 @@ tail_space(struct _tailblock *tail) return sizeof(tail->tb_data)/sizeof(tail->tb_data[0])-1; return &tail->tb_data[tail->tb_offset[tail->used-1]] - - (blockid_t *)&tail->tb_offset[tail->used]; + - (blockid_t *)&tail->tb_offset[tail->used] - 1; } #if 0 @@ -504,7 +507,7 @@ disk_add_list(struct _IBEXStore *store, blockid_t *headptr, blockid_t *tailptr, } } else { tailblock = (struct _tailblock *)ibex_block_read(store->blocks, TAIL_BLOCK(tail)); - len = tail_info(tailblock, tail, &start); + len = tail_info(store->blocks, tailblock, tail, &start); /* case 3 */ if (len + data->len >= TAIL_THRESHOLD) { /* this is suboptimal, but should work - merge the tail data with @@ -542,7 +545,7 @@ disk_add_list(struct _IBEXStore *store, blockid_t *headptr, blockid_t *tailptr, /* read/merge the tail with the new data, rewrite out. suboptimal, but it should be 'ok' ? */ tailblock = (struct _tailblock *)ibex_block_read(store->blocks, TAIL_BLOCK(tail)); - len = tail_info(tailblock, tail, &start); + len = tail_info(store->blocks, tailblock, tail, &start); tmpdata = g_array_new(0, 0, sizeof(blockid_t)); g_array_append_vals(tmpdata, start, len); g_array_append_vals(tmpdata, data->data, data->len); @@ -610,7 +613,7 @@ disk_remove(struct _IBEXStore *store, blockid_t *headptr, blockid_t *tailptr, na int len; blockid_t *start; - len = tail_info(tailblock, tail, &start); + len = tail_info(store->blocks, tailblock, tail, &start); for (i=0;i<len;i++) { if (start[i] == data) { for (;i<len-1;i++) @@ -688,7 +691,7 @@ disk_find(struct _IBEXStore *store, blockid_t head, blockid_t tail, nameid_t dat int len; blockid_t *start; - len = tail_info(tailblock, tail, &start); + len = tail_info(store->blocks, tailblock, tail, &start); for (i=0;i<len;i++) { if (start[i] == data) return TRUE; @@ -725,7 +728,7 @@ disk_get(struct _IBEXStore *store, blockid_t head, blockid_t tail) blockid_t *start; tailblock = (struct _tailblock *)ibex_block_read(store->blocks, TAIL_BLOCK(tail)); - len = tail_info(tailblock, tail, &start); + len = tail_info(store->blocks, tailblock, tail, &start); g_array_append_vals(result, start, len); } return result; @@ -764,7 +767,7 @@ ibex_diskarray_dump(struct _memcache *blocks, blockid_t head, blockid_t tail) int i; tailblock = (struct _tailblock *)ibex_block_read(blocks, TAIL_BLOCK(tail)); - len = tail_info(tailblock, tail, &start); + len = tail_info(blocks, tailblock, tail, &start); for (i=0;i<len;i++) printf(" %d", start[i]); } |