Skip to content

Commit

Permalink
mapper: do not store the offset, it's not used anywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed May 25, 2024
1 parent 82b9d56 commit 8d0d068
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
13 changes: 0 additions & 13 deletions libsqsh/include/sqsh_mapper_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ struct SqshMapSlice {
* @privatesection
*/
struct SqshMapper *mapper;
sqsh_index_t offset;
size_t size;
uint8_t *data;
};
Expand All @@ -138,18 +137,6 @@ struct SqshMapSlice {
SQSH_NO_EXPORT const uint8_t *
sqsh__map_slice_data(const struct SqshMapSlice *mapping);

/**
* @internal
* @memberof SqshMapSlice
* @brief Retrieves the offset of a mapping.
*
* @param[in] mapping The mapping to retrieve the offset from.
*
* @return The data in the mapping.
*/
SQSH_NO_EXPORT size_t
sqsh__map_slice_offset(const struct SqshMapSlice *mapping);

/**
* @internal
* @memberof SqshMapSlice
Expand Down
11 changes: 3 additions & 8 deletions libsqsh/src/mapper/map_slice.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ sqsh__map_slice_init(
return -SQSH_ERROR_SIZE_MISMATCH;
}
mapping->mapper = mapper;
mapping->offset = offset;
mapping->size = size;
return mapper->impl->map(mapper, offset, size, &mapping->data);
}
Expand All @@ -68,18 +67,14 @@ sqsh__map_slice_size(const struct SqshMapSlice *mapping) {
return mapping->size;
}

size_t
sqsh__map_slice_offset(const struct SqshMapSlice *mapping) {
return mapping->offset;
}

int
sqsh__map_slice_cleanup(struct SqshMapSlice *mapping) {
int rv = 0;

if (mapping->mapper) {
rv = mapping->mapper->impl->unmap(
mapping->mapper, mapping->data, mapping->size);
uint8_t *data = mapping->data;
size_t size = sqsh__map_slice_size(mapping);
rv = mapping->mapper->impl->unmap(mapping->mapper, data, size);
}
mapping->mapper = NULL;
return rv;
Expand Down

0 comments on commit 8d0d068

Please sign in to comment.