From bce944d1498eaa3b6940ee234c863b3548a66b37 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 24 Jan 2021 12:00:11 -0500 Subject: graphics! --- src/user/libfont/filist.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/user/libfont/filist.c (limited to 'src/user/libfont/filist.c') diff --git a/src/user/libfont/filist.c b/src/user/libfont/filist.c new file mode 100644 index 0000000..ae24429 --- /dev/null +++ b/src/user/libfont/filist.c @@ -0,0 +1,33 @@ +#include +#include +#include + +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; +} \ No newline at end of file -- cgit v1.2.3