c-md/includes/map.h.md

1.2 KiB

map.h

Include Guard

#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.

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.

typedef struct s_map
{
	t_range	*ranges;
	size_t	count;
	size_t	capacity;
}	t_map;

Functions

map_init

Initialize a mapping structure.

void
map_init(t_map *map);

map_add

Add a new mapping range to the mapping structure.

void
map_add(t_map *map, uint32_t src_start, uint32_t src_end,
	uint32_t dst_start, uint32_t dst_end);

map_write

Write the mapping information to a file.

int8_t
map_write(t_map *map, const char *path, const char *source, const char *target);

map_free

Free the resources associated with the mapping structure.

void
map_free(t_map *map);

End Guard

#endif