summaryrefslogtreecommitdiff
path: root/usr.bin/vtfontcvt
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2015-08-31 23:08:39 +0000
committerEd Maste <emaste@FreeBSD.org>2015-08-31 23:08:39 +0000
commit2e268aa950c6469ffb3e5dba8d2d36c3021d969e (patch)
tree21f1517c52516e27730023b6418fe23e0314a7b3 /usr.bin/vtfontcvt
parent73457dc3575375b5f1df230db2867384a0030a4e (diff)
downloadsrc-test2-2e268aa950c6469ffb3e5dba8d2d36c3021d969e.tar.gz
src-test2-2e268aa950c6469ffb3e5dba8d2d36c3021d969e.zip
Notes
Diffstat (limited to 'usr.bin/vtfontcvt')
-rw-r--r--usr.bin/vtfontcvt/vtfontcvt.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/vtfontcvt/vtfontcvt.c b/usr.bin/vtfontcvt/vtfontcvt.c
index 07c354768f90..f2c69d2060af 100644
--- a/usr.bin/vtfontcvt/vtfontcvt.c
+++ b/usr.bin/vtfontcvt/vtfontcvt.c
@@ -96,6 +96,16 @@ usage(void)
exit(1);
}
+static void *
+xmalloc(size_t size)
+{
+ void *m;
+
+ if ((m = malloc(size)) == NULL)
+ errx(1, "memory allocation failure");
+ return (m);
+}
+
static int
add_mapping(struct glyph *gl, unsigned int c, unsigned int map_idx)
{
@@ -104,7 +114,7 @@ add_mapping(struct glyph *gl, unsigned int c, unsigned int map_idx)
mapping_total++;
- mp = malloc(sizeof *mp);
+ mp = xmalloc(sizeof *mp);
mp->m_char = c;
mp->m_glyph = gl;
mp->m_length = 0;
@@ -163,8 +173,8 @@ add_glyph(const uint8_t *bytes, unsigned int map_idx, int fallback)
}
}
- gl = malloc(sizeof *gl);
- gl->g_data = malloc(wbytes * height);
+ gl = xmalloc(sizeof *gl);
+ gl->g_data = xmalloc(wbytes * height);
memcpy(gl->g_data, bytes, wbytes * height);
if (fallback)
TAILQ_INSERT_HEAD(&glyphs[map_idx], gl, g_list);