Skip to content

Commit 4fdca15

Browse files
committed
Slight name change with ctz skip-list functions
changed: lfs_index -> lfs_ctz_index lfs_index_find -> lfs_ctz_find lfs_index_append -> lfs_ctz_append lfs_index_traverse -> lfs_ctz_traverse
1 parent 454b588 commit 4fdca15

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lfs.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir) {
10031003

10041004

10051005
/// File index list operations ///
1006-
static int lfs_index(lfs_t *lfs, lfs_off_t *off) {
1006+
static int lfs_ctz_index(lfs_t *lfs, lfs_off_t *off) {
10071007
lfs_off_t i = 0;
10081008

10091009
while (*off >= lfs->cfg->block_size) {
@@ -1015,7 +1015,7 @@ static int lfs_index(lfs_t *lfs, lfs_off_t *off) {
10151015
return i;
10161016
}
10171017

1018-
static int lfs_index_find(lfs_t *lfs,
1018+
static int lfs_ctz_find(lfs_t *lfs,
10191019
lfs_cache_t *rcache, const lfs_cache_t *pcache,
10201020
lfs_block_t head, lfs_size_t size,
10211021
lfs_size_t pos, lfs_block_t *block, lfs_off_t *off) {
@@ -1025,8 +1025,8 @@ static int lfs_index_find(lfs_t *lfs,
10251025
return 0;
10261026
}
10271027

1028-
lfs_off_t current = lfs_index(lfs, &(lfs_off_t){size-1});
1029-
lfs_off_t target = lfs_index(lfs, &pos);
1028+
lfs_off_t current = lfs_ctz_index(lfs, &(lfs_off_t){size-1});
1029+
lfs_off_t target = lfs_ctz_index(lfs, &pos);
10301030

10311031
while (current > target) {
10321032
lfs_size_t skip = lfs_min(
@@ -1047,7 +1047,7 @@ static int lfs_index_find(lfs_t *lfs,
10471047
return 0;
10481048
}
10491049

1050-
static int lfs_index_extend(lfs_t *lfs,
1050+
static int lfs_ctz_extend(lfs_t *lfs,
10511051
lfs_cache_t *rcache, lfs_cache_t *pcache,
10521052
lfs_block_t head, lfs_size_t size,
10531053
lfs_off_t *block, lfs_block_t *off) {
@@ -1073,7 +1073,7 @@ static int lfs_index_extend(lfs_t *lfs,
10731073
}
10741074

10751075
size -= 1;
1076-
lfs_off_t index = lfs_index(lfs, &size);
1076+
lfs_off_t index = lfs_ctz_index(lfs, &size);
10771077
size += 1;
10781078

10791079
// just copy out the last block if it is incomplete
@@ -1133,15 +1133,15 @@ static int lfs_index_extend(lfs_t *lfs,
11331133
}
11341134
}
11351135

1136-
static int lfs_index_traverse(lfs_t *lfs,
1136+
static int lfs_ctz_traverse(lfs_t *lfs,
11371137
lfs_cache_t *rcache, const lfs_cache_t *pcache,
11381138
lfs_block_t head, lfs_size_t size,
11391139
int (*cb)(void*, lfs_block_t), void *data) {
11401140
if (size == 0) {
11411141
return 0;
11421142
}
11431143

1144-
lfs_off_t index = lfs_index(lfs, &(lfs_off_t){size-1});
1144+
lfs_off_t index = lfs_ctz_index(lfs, &(lfs_off_t){size-1});
11451145

11461146
while (true) {
11471147
int err = cb(data, head);
@@ -1455,7 +1455,7 @@ lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file,
14551455
// check if we need a new block
14561456
if (!(file->flags & LFS_F_READING) ||
14571457
file->off == lfs->cfg->block_size) {
1458-
int err = lfs_index_find(lfs, &file->cache, NULL,
1458+
int err = lfs_ctz_find(lfs, &file->cache, NULL,
14591459
file->head, file->size,
14601460
file->pos, &file->block, &file->off);
14611461
if (err) {
@@ -1522,7 +1522,7 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file,
15221522
file->off == lfs->cfg->block_size) {
15231523
if (!(file->flags & LFS_F_WRITING) && file->pos > 0) {
15241524
// find out which block we're extending from
1525-
int err = lfs_index_find(lfs, &file->cache, NULL,
1525+
int err = lfs_ctz_find(lfs, &file->cache, NULL,
15261526
file->head, file->size,
15271527
file->pos-1, &file->block, &file->off);
15281528
if (err) {
@@ -1535,7 +1535,7 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file,
15351535

15361536
// extend file with new blocks
15371537
lfs_alloc_ack(lfs);
1538-
int err = lfs_index_extend(lfs, &lfs->rcache, &file->cache,
1538+
int err = lfs_ctz_extend(lfs, &lfs->rcache, &file->cache,
15391539
file->block, file->pos,
15401540
&file->block, &file->off);
15411541
if (err) {
@@ -2070,7 +2070,7 @@ int lfs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data) {
20702070

20712071
dir.off += lfs_entry_size(&entry);
20722072
if ((0x70 & entry.d.type) == (0x70 & LFS_TYPE_REG)) {
2073-
int err = lfs_index_traverse(lfs, &lfs->rcache, NULL,
2073+
int err = lfs_ctz_traverse(lfs, &lfs->rcache, NULL,
20742074
entry.d.u.file.head, entry.d.u.file.size, cb, data);
20752075
if (err) {
20762076
return err;
@@ -2089,15 +2089,15 @@ int lfs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data) {
20892089
// iterate over any open files
20902090
for (lfs_file_t *f = lfs->files; f; f = f->next) {
20912091
if (f->flags & LFS_F_DIRTY) {
2092-
int err = lfs_index_traverse(lfs, &lfs->rcache, &f->cache,
2092+
int err = lfs_ctz_traverse(lfs, &lfs->rcache, &f->cache,
20932093
f->head, f->size, cb, data);
20942094
if (err) {
20952095
return err;
20962096
}
20972097
}
20982098

20992099
if (f->flags & LFS_F_WRITING) {
2100-
int err = lfs_index_traverse(lfs, &lfs->rcache, &f->cache,
2100+
int err = lfs_ctz_traverse(lfs, &lfs->rcache, &f->cache,
21012101
f->block, f->pos, cb, data);
21022102
if (err) {
21032103
return err;

0 commit comments

Comments
 (0)