s502 assembler
A very simple assembler for the 6502 line of processors written in C
map.h
Go to the documentation of this file.
1 #ifndef GUARD_MAP
2 #define GUARD_MAP
3 
12 enum {
14  MAP_MAX_KEY_LEN = 32
15 };
16 
18 struct MapEntry {
20  int value;
24  struct MapEntry* next;
25 };
26 
34 typedef struct {
35  struct MapEntry* head;
36 } Map;
37 
43 Map* map_new();
44 
53 int map_set(Map* map, char* name, int value);
54 
62 int map_get(Map* map, char* name);
63 
64 
72 void map_free(Map* map);
73 
81 void map_debug_print(Map* map);
82 
83 #endif
Map::head
struct MapEntry * head
Definition: map.h:35
Map::map_set
int map_set(Map *map, char *name, int value)
Sets a key in the map.
Definition: map.c:43
Map::map_debug_print
void map_debug_print(Map *map)
Print all key-value pairs of the map.
Definition: map.c:85
MapEntry
One entry in a map.
Definition: map.h:18
Map
Simple key->value map (str->int)
Definition: map.h:34
MapEntry::next
struct MapEntry * next
pointer to the next entry or NULL
Definition: map.h:24
Map::map_free
void map_free(Map *map)
Free the map with all associated memory.
Definition: map.c:62
Map::map_get
int map_get(Map *map, char *name)
Get the value of a key.
Definition: map.c:75
MapEntry::name
char name[MAP_MAX_KEY_LEN]
key of the entry
Definition: map.h:22
MAP_MAX_KEY_LEN
@ MAP_MAX_KEY_LEN
Key buffer size for Map.
Definition: map.h:14
Map::map_new
Map * map_new()
Create a new map with 0 elements.
Definition: map.c:17
MapEntry::value
int value
the value the entry holds
Definition: map.h:20