aboutsummaryrefslogtreecommitdiff
path: root/font.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-10-16 19:52:12 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-10-16 19:52:12 +0000
commita789230cf9f87c68fcced647d0a1e8edc516f1c2 (patch)
tree13ae47436e665872f368795d2ec3e7881070f247 /font.c
parentselection: replace \r\n with \n in pasted text (diff)
font: font_from_name() returns an allocated font struct
Diffstat (limited to 'font.c')
-rw-r--r--font.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/font.c b/font.c
index 049a3be8..b68e341c 100644
--- a/font.c
+++ b/font.c
@@ -291,8 +291,8 @@ from_name(const char *base_name, const font_list_t *fallbacks, const char *attri
return true;
}
-bool
-font_from_name(font_list_t names, const char *attributes, struct font *font)
+struct font *
+font_from_name(font_list_t names, const char *attributes)
{
if (tll_length(names) == 0)
return false;
@@ -308,10 +308,14 @@ font_from_name(font_list_t names, const char *attributes, struct font *font)
tll_push_back(fallbacks, it->item);
}
+ struct font *font = malloc(sizeof(*font));
bool ret = from_name(tll_front(names), &fallbacks, attributes, font, false);
+ if (!ret)
+ free(font);
+
tll_free(fallbacks);
- return ret;
+ return ret ? font : NULL;
}
static size_t