Skip to content

Commit

Permalink
map_reader: use SqshReader2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed Aug 16, 2023
1 parent cd97dba commit a4a3bd6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
3 changes: 2 additions & 1 deletion include/sqsh_mapper_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "sqsh_mapper.h"

#include "sqsh_primitive_private.h"
#include "sqsh_reader_private.h"
#include "sqsh_thread_private.h"
#include <sys/wait.h>

Expand Down Expand Up @@ -480,7 +481,7 @@ struct SqshMapReader {
uint64_t address;
uint64_t upper_limit;
struct SqshMapIterator iterator;
struct SqshReader reader;
struct SqshReader2 reader;
};

/**
Expand Down
25 changes: 7 additions & 18 deletions lib/mapper/map_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ map_iterator_next(void *iterator, size_t desired_size) {
(void)desired_size;
return sqsh__map_iterator_next(iterator);
}
static int
map_iterator_skip(void *iterator, size_t amount, size_t desired_size) {
(void)desired_size;
return sqsh__map_iterator_skip(iterator, amount);
}
static size_t
map_iterator_block_size(const void *iterator) {
return sqsh__map_iterator_block_size(iterator);
}
static const uint8_t *
map_iterator_data(const void *iterator) {
return sqsh__map_iterator_data(iterator);
Expand All @@ -59,10 +50,8 @@ map_iterator_size(const void *iterator) {
return sqsh__map_iterator_size(iterator);
}

static const struct SqshIteratorImpl map_reader_impl = {
static const struct SqshReader2IteratorImpl map_reader_impl = {
.next = map_iterator_next,
.skip = map_iterator_skip,
.block_size = map_iterator_block_size,
.data = map_iterator_data,
.size = map_iterator_size,
};
Expand All @@ -85,15 +74,15 @@ sqsh__map_reader_init(
if (rv < 0) {
goto out;
}
rv = sqsh__reader_init(
rv = sqsh__reader2_init(
&reader->reader, &map_reader_impl, &reader->iterator);
if (rv < 0) {
goto out;
}
reader->upper_limit = upper_limit;
reader->address = start_address;

rv = sqsh__reader_advance(&reader->reader, offset, 0);
rv = sqsh__reader2_advance(&reader->reader, offset, 0);
out:
if (rv < 0) {
sqsh__map_reader_cleanup(reader);
Expand All @@ -117,7 +106,7 @@ int
sqsh__map_reader_advance(
struct SqshMapReader *reader, sqsh_index_t offset, size_t size) {
reader->address += offset;
return sqsh__reader_advance(&reader->reader, offset, size);
return sqsh__reader2_advance(&reader->reader, offset, size);
}

int
Expand All @@ -128,17 +117,17 @@ sqsh__map_reader_all(struct SqshMapReader *reader) {

const uint8_t *
sqsh__map_reader_data(const struct SqshMapReader *reader) {
return sqsh__reader_data(&reader->reader);
return sqsh__reader2_data(&reader->reader);
}

size_t
sqsh__map_reader_size(const struct SqshMapReader *reader) {
return sqsh__reader_size(&reader->reader);
return sqsh__reader2_size(&reader->reader);
}

int
sqsh__map_reader_cleanup(struct SqshMapReader *reader) {
sqsh__reader_cleanup(&reader->reader);
sqsh__reader2_cleanup(&reader->reader);
sqsh__map_iterator_cleanup(&reader->iterator);

return 0;
Expand Down

0 comments on commit a4a3bd6

Please sign in to comment.