diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2012-07-05 11:35:48 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-07-05 11:35:48 -0700 |
commit | 38182d901d030c7d65f4aa7a49b583afb30eb9b7 (patch) | |
tree | a69e1a571495d6ca1c034359d7c995639774ab9b /src/ftfont.c | |
parent | 6dd5a677dbf794eedaa8325c46d57ac041373361 (diff) |
More xmalloc and related cleanup.
* alloc.c, bidi.c, buffer.c, buffer.h, bytecode.c, callint.c:
* callproc.c, charset.c, coding.c, composite.c, data.c, dispnew.c:
* doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, fns.c:
* font.c, fontset.c, frame.c, fringe.c, ftfont.c, ftxfont.c, gmalloc.c:
* gtkutil.c, image.c, keyboard.c, keymap.c, lread.c, macros.c, menu.c:
* nsfns.m, nsfont.m, nsmenu.m, nsterm.m, print.c, process.c, ralloc.c:
* regex.c, region-cache.c, scroll.c, search.c, sound.c, syntax.c:
* sysdep.c, term.c, termcap.c, unexmacosx.c, window.c, xdisp.c:
* xfaces.c, xfns.c, xftfont.c, xgselect.c, xmenu.c, xrdb.c, xselect.c:
* xterm.c:
Omit needless casts involving void * pointers and allocation.
Prefer "P = xmalloc (sizeof *P)" to "P = xmalloc (sizeof (TYPE_OF_P))",
as the former is more robust if P's type is changed.
Prefer xzalloc to xmalloc + memset 0.
Simplify malloc-or-realloc to realloc.
Don't worry about xmalloc returning a null pointer.
Prefer xstrdup to xmalloc + strcpy.
* editfns.c (Fmessage_box): Grow message_text by at least 80 when
growing it.
* keyboard.c (apply_modifiers_uncached): Prefer local array to
alloca of a constant.
Diffstat (limited to 'src/ftfont.c')
-rw-r--r-- | src/ftfont.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/ftfont.c b/src/ftfont.c index 29732e4c870..8e322369868 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -392,7 +392,7 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for) args[1] = Qequal; ft_face_cache = Fmake_hash_table (2, args); } - cache_data = xmalloc (sizeof (struct ftfont_cache_data)); + cache_data = xmalloc (sizeof *cache_data); cache_data->ft_face = NULL; cache_data->fc_charset = NULL; val = make_save_value (NULL, 0); @@ -657,7 +657,7 @@ struct OpenTypeSpec static struct OpenTypeSpec * ftfont_get_open_type_spec (Lisp_Object otf_spec) { - struct OpenTypeSpec *spec = malloc (sizeof (struct OpenTypeSpec)); + struct OpenTypeSpec *spec = malloc (sizeof *spec); Lisp_Object val; int i, j, negative; @@ -696,7 +696,7 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec) spec->features[i] = (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < XINT (len) ? 0 - : malloc (sizeof (int) * XINT (len))); + : malloc (XINT (len) * sizeof *spec->features[i])); if (! spec->features[i]) { if (i > 0 && spec->features[0]) @@ -2460,15 +2460,16 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, if (gstring.allocated == 0) { gstring.glyph_size = sizeof (MFLTGlyph); - gstring.glyphs = xnmalloc (len * 2, sizeof (MFLTGlyph)); + gstring.glyphs = xnmalloc (len * 2, sizeof *gstring.glyphs); gstring.allocated = len * 2; } else if (gstring.allocated < len * 2) { - gstring.glyphs = xnrealloc (gstring.glyphs, len * 2, sizeof (MFLTGlyph)); + gstring.glyphs = xnrealloc (gstring.glyphs, len * 2, + sizeof *gstring.glyphs); gstring.allocated = len * 2; } - memset (gstring.glyphs, 0, sizeof (MFLTGlyph) * len); + memset (gstring.glyphs, 0, len * sizeof *gstring.glyphs); for (i = 0; i < len; i++) { Lisp_Object g = LGSTRING_GLYPH (lgstring, i); |