blob: ae244297f1ee13039a92b43f2d6c83524e2e0301 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include <libfont/fonts.h>
#include <knob/block.h>
#include <knob/heap.h>
struct dict_entry {
char *name;
struct font_info *fi;
struct dict_entry *prev;
} *last_entry = 0;
__attribute__ ((pure))
struct font_info *find_entry(const char *name) {
for (struct dict_entry *i = last_entry; i; i = i->prev)
if (strequ(i->name, name))
return i->fi;
return 0;
}
struct font_info *new_entry(const char *name) {
struct dict_entry *const nde = get_block(sizeof(struct dict_entry));
nde->name = strdup(name);
nde->fi = get_block(sizeof(struct font_info));
nde->prev = last_entry;
last_entry = nde;
return nde->fi;
}
void del_last() {//only called when last_entry isn't 0
free_block(last_entry->name);
free_block(last_entry->fi);
free_block(last_entry);
last_entry = last_entry->prev;
}
|