changeset 85245:8188d7d7f4c5

(GROW_RAW_KEYBUF, menu_bar_items, menu_bar_item, append_tool_bar_item): Use larger_vector.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 13 Oct 2007 12:08:42 +0000
parents 8a6c1b0352a2
children ef39b2bc8f1e
files src/keyboard.c
diffstat 1 files changed, 5 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Sat Oct 13 12:07:41 2007 +0000
+++ b/src/keyboard.c	Sat Oct 13 12:08:42 2007 +0000
@@ -160,14 +160,7 @@
 
 #define GROW_RAW_KEYBUF							\
  if (raw_keybuf_count == XVECTOR (raw_keybuf)->size)			\
-  {									\
-    int newsize = 2 * XVECTOR (raw_keybuf)->size;			\
-    Lisp_Object new;							\
-    new = Fmake_vector (make_number (newsize), Qnil);			\
-    bcopy (XVECTOR (raw_keybuf)->contents, XVECTOR (new)->contents,	\
-	   raw_keybuf_count * sizeof (Lisp_Object));			\
-    raw_keybuf = new;							\
-  }
+   raw_keybuf = larger_vector (raw_keybuf, raw_keybuf_count * 2, Qnil)  \
 
 /* Number of elements of this_command_keys
    that precede this key sequence.  */
@@ -7598,13 +7591,7 @@
   /* Add nil, nil, nil, nil at the end.  */
   i = menu_bar_items_index;
   if (i + 4 > XVECTOR (menu_bar_items_vector)->size)
-    {
-      Lisp_Object tem;
-      tem = Fmake_vector (make_number (2 * i), Qnil);
-      bcopy (XVECTOR (menu_bar_items_vector)->contents,
-	     XVECTOR (tem)->contents, i * sizeof (Lisp_Object));
-      menu_bar_items_vector = tem;
-    }
+    menu_bar_items_vector = larger_vector (menu_bar_items_vector, 2 * i, Qnil);
   /* Add this item.  */
   XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
   XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
@@ -7676,14 +7663,7 @@
     {
       /* If vector is too small, get a bigger one.  */
       if (i + 4 > XVECTOR (menu_bar_items_vector)->size)
-	{
-	  Lisp_Object tem;
-	  tem = Fmake_vector (make_number (2 * i), Qnil);
-	  bcopy (XVECTOR (menu_bar_items_vector)->contents,
-		 XVECTOR (tem)->contents, i * sizeof (Lisp_Object));
-	  menu_bar_items_vector = tem;
-	}
-
+	menu_bar_items_vector = larger_vector (menu_bar_items_vector, 2 * i, Qnil);
       /* Add this item.  */
       XVECTOR (menu_bar_items_vector)->contents[i++] = key;
       XVECTOR (menu_bar_items_vector)->contents[i++]
@@ -8452,16 +8432,8 @@
   /* Enlarge tool_bar_items_vector if necessary.  */
   if (ntool_bar_items + TOOL_BAR_ITEM_NSLOTS
       >= XVECTOR (tool_bar_items_vector)->size)
-    {
-      Lisp_Object new_vector;
-      int old_size = XVECTOR (tool_bar_items_vector)->size;
-
-      new_vector = Fmake_vector (make_number (2 * old_size), Qnil);
-      bcopy (XVECTOR (tool_bar_items_vector)->contents,
-	     XVECTOR (new_vector)->contents,
-	     old_size * sizeof (Lisp_Object));
-      tool_bar_items_vector = new_vector;
-    }
+    tool_bar_items_vector = larger_vector
+      (tool_bar_items_vector, 2 * XVECTOR (tool_bar_items_vector)->size, Qnil);
 
   /* Append entries from tool_bar_item_properties to the end of
      tool_bar_items_vector.  */