72 lines
1.2 KiB
Markdown
72 lines
1.2 KiB
Markdown
# map.h
|
|
|
|
## Include Guard
|
|
```c
|
|
#ifndef MAP_H
|
|
# define MAP_H
|
|
|
|
# include <stddef.h>
|
|
# include <stdint.h>
|
|
```
|
|
|
|
## Types
|
|
|
|
### `t_range`
|
|
A structure representing a mapping range between source and destination
|
|
addresses.
|
|
```c
|
|
typedef struct s_range
|
|
{
|
|
uint32_t src_start;
|
|
uint32_t src_end;
|
|
uint32_t dst_start;
|
|
uint32_t dst_end;
|
|
} t_range;
|
|
```
|
|
|
|
### `t_map`
|
|
A structure representing a collection of mapping ranges.
|
|
```c
|
|
typedef struct s_map
|
|
{
|
|
t_range *ranges;
|
|
size_t count;
|
|
size_t capacity;
|
|
} t_map;
|
|
```
|
|
|
|
## Functions
|
|
|
|
### [`map_init`](/srcs/map/core.c.md#map_init)
|
|
Initialize a mapping structure.
|
|
```c
|
|
void
|
|
map_init(t_map *map);
|
|
```
|
|
|
|
### [`map_add`](/srcs/map/core.c.md#map_add)
|
|
Add a new mapping range to the mapping structure.
|
|
```c
|
|
void
|
|
map_add(t_map *map, uint32_t src_start, uint32_t src_end,
|
|
uint32_t dst_start, uint32_t dst_end);
|
|
```
|
|
|
|
### [`map_write`](/srcs/map/io.c.md#map_write)
|
|
Write the mapping information to a file.
|
|
```c
|
|
int8_t
|
|
map_write(t_map *map, const char *path, const char *source, const char *target);
|
|
```
|
|
|
|
### [`map_free`](/srcs/map/core.c.md#map_free)
|
|
Free the resources associated with the mapping structure.
|
|
```c
|
|
void
|
|
map_free(t_map *map);
|
|
```
|
|
|
|
## End Guard
|
|
```c
|
|
#endif
|
|
```
|