summaryrefslogtreecommitdiff
path: root/src/frame.c
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/frame.c
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/frame.c')
-rw-r--r--src/frame.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/frame.c b/src/frame.c
index 6ff336c40ee..8db943bd0a5 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -647,7 +647,7 @@ affects all frames on the same terminal device. */)
: NULL));
if (!NILP (tty))
{
- name = (char *) alloca (SBYTES (tty) + 1);
+ name = alloca (SBYTES (tty) + 1);
strncpy (name, SSDATA (tty), SBYTES (tty));
name[SBYTES (tty)] = 0;
}
@@ -658,7 +658,7 @@ affects all frames on the same terminal device. */)
: NULL));
if (!NILP (tty_type))
{
- type = (char *) alloca (SBYTES (tty_type) + 1);
+ type = alloca (SBYTES (tty_type) + 1);
strncpy (type, SSDATA (tty_type), SBYTES (tty_type));
type[SBYTES (tty_type)] = 0;
}
@@ -2762,8 +2762,8 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist)
for (tail = alist; CONSP (tail); tail = Fcdr (tail))
i++;
- parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
- values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
+ parms = alloca (i * sizeof *parms);
+ values = alloca (i * sizeof *values);
/* Extract parm names and values into those vectors. */
@@ -3624,17 +3624,17 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li
/* Allocate space for the components, the dots which separate them,
and the final '\0'. Make them big enough for the worst case. */
- name_key = (char *) alloca (SBYTES (Vx_resource_name)
- + (STRINGP (component)
- ? SBYTES (component) : 0)
- + SBYTES (attribute)
- + 3);
-
- class_key = (char *) alloca (SBYTES (Vx_resource_class)
- + SBYTES (class)
- + (STRINGP (subclass)
- ? SBYTES (subclass) : 0)
- + 3);
+ name_key = alloca (SBYTES (Vx_resource_name)
+ + (STRINGP (component)
+ ? SBYTES (component) : 0)
+ + SBYTES (attribute)
+ + 3);
+
+ class_key = alloca (SBYTES (Vx_resource_class)
+ + SBYTES (class)
+ + (STRINGP (subclass)
+ ? SBYTES (subclass) : 0)
+ + 3);
/* Start with emacs.FRAMENAME for the name (the specific one)
and with `Emacs' for the class key (the general one). */
@@ -3710,8 +3710,7 @@ x_get_resource_string (const char *attribute, const char *class)
/* Allocate space for the components, the dots which separate them,
and the final '\0'. */
SAFE_ALLOCA (name_key, char *, invocation_namelen + strlen (attribute) + 2);
- class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
- + strlen (class) + 2);
+ class_key = alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2);
esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute);
sprintf (class_key, "%s.%s", EMACS_CLASS, class);