summaryrefslogtreecommitdiff
path: root/src/nsfont.m
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-07-05 11:35:48 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-07-05 11:35:48 -0700
commit38182d901d030c7d65f4aa7a49b583afb30eb9b7 (patch)
treea69e1a571495d6ca1c034359d7c995639774ab9b /src/nsfont.m
parent6dd5a677dbf794eedaa8325c46d57ac041373361 (diff)
downloademacs-38182d901d030c7d65f4aa7a49b583afb30eb9b7.tar.gz
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/nsfont.m')
-rw-r--r--src/nsfont.m20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/nsfont.m b/src/nsfont.m
index 556102b6f44..7a456c4bb5d 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -152,7 +152,7 @@ ns_spec_to_descriptor (Lisp_Object font_spec)
[fdAttrs setObject: tdict forKey: NSFontTraitsAttribute];
fdesc = [NSFontDescriptor fontDescriptorWithFontAttributes: fdAttrs];
- if (family != nil)
+ if (family != nil)
{
fdesc = [fdesc fontDescriptorWithFamily: family];
}
@@ -779,14 +779,8 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
if (!font)
return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */
- font_info->glyphs = (unsigned short **)
- xmalloc (0x100 * sizeof (unsigned short *));
- font_info->metrics = (struct font_metrics **)
- xmalloc (0x100 * sizeof (struct font_metrics *));
- if (!font_info->glyphs || !font_info->metrics)
- return Qnil;
- memset (font_info->glyphs, 0, 0x100 * sizeof (unsigned short *));
- memset (font_info->metrics, 0, 0x100 * sizeof (struct font_metrics *));
+ font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs);
+ font_info->metrics = xzalloc (0x100 * sizeof *font_info->metrics);
BLOCK_INPUT;
@@ -831,8 +825,7 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
[font_info->nsfont retain];
/* set up ns_font (defined in nsgui.h) */
- font_info->name = (char *)xmalloc (strlen (fontName)+1);
- strcpy (font_info->name, fontName);
+ font_info->name = xstrdup (fontName);
font_info->bold = [fontMgr traitsOfFont: nsfont] & NSBoldFontMask;
font_info->ital =
synthItal || ([fontMgr traitsOfFont: nsfont] & NSItalicFontMask);
@@ -1371,8 +1364,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
BLOCK_INPUT;
sfont = [font_info->nsfont screenFont];
- font_info->metrics[block] = xmalloc (0x100 * sizeof (struct font_metrics));
- memset (font_info->metrics[block], 0, 0x100 * sizeof (struct font_metrics));
+ font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics));
if (!(font_info->metrics[block]))
abort ();
@@ -1417,7 +1409,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
maxChar = 0;
maxGlyph = 0;
dict = [NSMutableDictionary new];
- cglyphs = (CGGlyph *)xmalloc (c * sizeof (CGGlyph));
+ cglyphs = xmalloc (c * sizeof (CGGlyph));
return self;
}