Skip to content

Commit

Permalink
mapper: remove allocation of SqshStaticMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed May 19, 2024
1 parent 5385a4e commit 5b64357
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
14 changes: 0 additions & 14 deletions libsqsh/include/sqsh_mapper_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,6 @@ struct SqshMmapMapper {
long page_size;
};

/***************************************
* mapper/static_mapper.c
*/

/**
* @brief The static mapper.
*/
struct SqshStaticMapper {
/**
* @privatesection
*/
const uint8_t *data;
};

/***************************************
* mapper/mapper.c
*/
Expand Down
14 changes: 3 additions & 11 deletions libsqsh/src/mapper/static_mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,29 @@
* @file static_mapper.c
*/

#include "sqsh_error.h"
#include <sqsh_mapper_private.h>
#include <stdlib.h>

static int
sqsh_mapper_static_mem_init(
struct SqshMapper *mapper, const void *input, size_t *size) {
(void)size;
struct SqshStaticMapper *user_data =
calloc(1, sizeof(struct SqshStaticMapper));
if (!user_data) {
return -SQSH_ERROR_MALLOC_FAILED;
}

user_data->data = input;
mapper->user_data = user_data;
mapper->user_data = (void *)input;

return 0;
}
static int
sqsh_mapper_static_mem_map(struct SqshMapSlice *mapping) {
struct SqshStaticMapper *user_data = mapping->mapper->user_data;
size_t offset = mapping->offset;
/* Cast to remove const qualifier. */
uint8_t *data = (uint8_t *)user_data->data;
uint8_t *data = mapping->mapper->user_data;
mapping->data = &data[offset];
return 0;
}
static int
sqsh_mapper_static_mem_cleanup(struct SqshMapper *mapper) {
free(mapper->user_data);
(void)mapper;
return 0;
}
static int
Expand Down

0 comments on commit 5b64357

Please sign in to comment.