changeset 70071:84e6726893ef

(XCreateGC, x_per_char_metric, xlfdpat_create) (init_font_name_table, init_font_name_table, mac_do_list_fonts) (XLoadQueryFont, mac_store_apple_event): Don't check return value of xmalloc.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Tue, 18 Apr 2006 08:13:28 +0000
parents 9559d7f62131
children 46e10feaefd1
files src/macterm.c
diffstat 1 files changed, 21 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/src/macterm.c	Tue Apr 18 08:12:31 2006 +0000
+++ b/src/macterm.c	Tue Apr 18 08:13:28 2006 +0000
@@ -1508,11 +1508,8 @@
 {
   GC gc = xmalloc (sizeof (*gc));
 
-  if (gc)
-    {
-      bzero (gc, sizeof (*gc));
-      XChangeGC (display, gc, mask, xgcv);
-    }
+  bzero (gc, sizeof (*gc));
+  XChangeGC (display, gc, mask, xgcv);
 
   return gc;
 }
@@ -2160,21 +2157,17 @@
       if (*row == NULL)
 	{
 	  *row = xmalloc (sizeof (XCharStructRow));
-	  if (*row)
-	    bzero (*row, sizeof (XCharStructRow));
+	  bzero (*row, sizeof (XCharStructRow));
 	}
-      if (*row)
+      pcm = (*row)->per_char + char2b->byte2;
+      if (!XCHARSTRUCTROW_CHAR_VALID_P (*row, char2b->byte2))
 	{
-	  pcm = (*row)->per_char + char2b->byte2;
-	  if (!XCHARSTRUCTROW_CHAR_VALID_P (*row, char2b->byte2))
-	    {
-	      BLOCK_INPUT;
-	      mac_query_char_extents (font->mac_style,
-				      (char2b->byte1 << 8) + char2b->byte2,
-				      NULL, NULL, pcm, NULL);
-	      UNBLOCK_INPUT;
-	      XCHARSTRUCTROW_SET_CHAR_VALID (*row, char2b->byte2);
-	    }
+	  BLOCK_INPUT;
+	  mac_query_char_extents (font->mac_style,
+				  (char2b->byte1 << 8) + char2b->byte2,
+				  NULL, NULL, pcm, NULL);
+	  UNBLOCK_INPUT;
+	  XCHARSTRUCTROW_SET_CHAR_VALID (*row, char2b->byte2);
 	}
     }
   else
@@ -6563,12 +6556,7 @@
   struct xlfdpat_block *blk;
 
   pat = xmalloc (sizeof (struct xlfdpat));
-  if (pat == NULL)
-    goto error;
-
   pat->buf = xmalloc (strlen (pattern) + 1);
-  if (pat->buf == NULL)
-    goto error;
 
   /* Normalize the pattern string and store it to `pat->buf'.  */
   nblocks = 0;
@@ -6632,8 +6620,6 @@
     }
 
   pat->blocks = xmalloc (sizeof (struct xlfdpat_block) * nblocks);
-  if (pat->blocks == NULL)
-    goto error;
 
   /* Divide the normalized pattern into blocks.  */
   p = pat->buf;
@@ -7093,9 +7079,10 @@
 			 Qnil, Qnil, Qnil);;
       err = ATSUFontCount (&nfonts);
       if (err == noErr)
-	font_ids = xmalloc (sizeof (ATSUFontID) * nfonts);
-      if (font_ids)
-	err = ATSUGetFontIDs (font_ids, nfonts, NULL);
+	{
+	  font_ids = xmalloc (sizeof (ATSUFontID) * nfonts);
+	  err = ATSUGetFontIDs (font_ids, nfonts, NULL);
+	}
       if (err == noErr)
 	for (i = 0; i < nfonts; i++)
 	  {
@@ -7105,8 +7092,6 @@
 	    if (err != noErr)
 	      continue;
 	    name = xmalloc (name_len + 1);
-	    if (name == NULL)
-	      continue;
 	    name[name_len] = '\0';
 	    err = ATSUFindFontName (font_ids[i], kFontFamilyName,
 				    kFontMacintoshPlatform, kFontNoScript,
@@ -7436,8 +7421,6 @@
 	  int former_len = ptr - font_name_table[i];
 
 	  scaled = xmalloc (strlen (font_name_table[i]) + 20 + 1);
-	  if (scaled == NULL)
-	    continue;
 	  memcpy (scaled, font_name_table[i], former_len);
 	  sprintf (scaled + former_len,
 		   "-%d-%d-72-72-m-%d-%s",
@@ -7770,18 +7753,8 @@
       font->max_char_or_byte2 = 0xff;
 
       font->bounds.rows = xmalloc (sizeof (XCharStructRow *) * 0x100);
-      if (font->bounds.rows == NULL)
-	{
-	  mac_unload_font (&one_mac_display_info, font);
-	  return NULL;
-	}
       bzero (font->bounds.rows, sizeof (XCharStructRow *) * 0x100);
       font->bounds.rows[0] = xmalloc (sizeof (XCharStructRow));
-      if (font->bounds.rows[0] == NULL)
-	{
-	  mac_unload_font (&one_mac_display_info, font);
-	  return NULL;
-	}
       bzero (font->bounds.rows[0], sizeof (XCharStructRow));
 
 #if USE_CG_TEXT_DRAWING
@@ -7803,9 +7776,10 @@
       }
 
       if (font->cg_font)
-	font->cg_glyphs = xmalloc (sizeof (CGGlyph) * 0x100);
-      if (font->cg_glyphs)
-	bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100);
+	{
+	  font->cg_glyphs = xmalloc (sizeof (CGGlyph) * 0x100);
+	  bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100);
+	}
 #endif
       space_bounds = font->bounds.rows[0]->per_char + 0x20;
       err = mac_query_char_extents (font->mac_style, 0x20,
@@ -7951,11 +7925,6 @@
 
 	  font->bounds.per_char =
 	    xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1));
-	  if (font->bounds.per_char == NULL)
-	    {
-	      mac_unload_font (&one_mac_display_info, font);
-	      return NULL;
-	    }
 	  bzero (font->bounds.per_char,
 		 sizeof (XCharStruct) * (0xff - 0x20 + 1));
 
@@ -8958,15 +8927,12 @@
      Lisp_Object class, id;
      const AEDesc *desc;
 {
-  OSErr err = noErr;
+  OSErr err;
   struct input_event buf;
   AEDesc *desc_copy;
 
   desc_copy = xmalloc (sizeof (AEDesc));
-  if (desc_copy == NULL)
-    err = memFullErr;
-  else
-    err = AEDuplicateDesc (desc, desc_copy);
+  err = AEDuplicateDesc (desc, desc_copy);
   if (err == noErr)
     {
       EVENT_INIT (buf);