diff options
| author | Paul Eggert | 2012-07-05 11:35:48 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-07-05 11:35:48 -0700 |
| commit | 38182d901d030c7d65f4aa7a49b583afb30eb9b7 (patch) | |
| tree | a69e1a571495d6ca1c034359d7c995639774ab9b /src/frame.c | |
| parent | 6dd5a677dbf794eedaa8325c46d57ac041373361 (diff) | |
| download | emacs-38182d901d030c7d65f4aa7a49b583afb30eb9b7.tar.gz emacs-38182d901d030c7d65f4aa7a49b583afb30eb9b7.zip | |
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.c | 33 |
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. */) | |||
| 647 | : NULL)); | 647 | : NULL)); |
| 648 | if (!NILP (tty)) | 648 | if (!NILP (tty)) |
| 649 | { | 649 | { |
| 650 | name = (char *) alloca (SBYTES (tty) + 1); | 650 | name = alloca (SBYTES (tty) + 1); |
| 651 | strncpy (name, SSDATA (tty), SBYTES (tty)); | 651 | strncpy (name, SSDATA (tty), SBYTES (tty)); |
| 652 | name[SBYTES (tty)] = 0; | 652 | name[SBYTES (tty)] = 0; |
| 653 | } | 653 | } |
| @@ -658,7 +658,7 @@ affects all frames on the same terminal device. */) | |||
| 658 | : NULL)); | 658 | : NULL)); |
| 659 | if (!NILP (tty_type)) | 659 | if (!NILP (tty_type)) |
| 660 | { | 660 | { |
| 661 | type = (char *) alloca (SBYTES (tty_type) + 1); | 661 | type = alloca (SBYTES (tty_type) + 1); |
| 662 | strncpy (type, SSDATA (tty_type), SBYTES (tty_type)); | 662 | strncpy (type, SSDATA (tty_type), SBYTES (tty_type)); |
| 663 | type[SBYTES (tty_type)] = 0; | 663 | type[SBYTES (tty_type)] = 0; |
| 664 | } | 664 | } |
| @@ -2762,8 +2762,8 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist) | |||
| 2762 | for (tail = alist; CONSP (tail); tail = Fcdr (tail)) | 2762 | for (tail = alist; CONSP (tail); tail = Fcdr (tail)) |
| 2763 | i++; | 2763 | i++; |
| 2764 | 2764 | ||
| 2765 | parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object)); | 2765 | parms = alloca (i * sizeof *parms); |
| 2766 | values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object)); | 2766 | values = alloca (i * sizeof *values); |
| 2767 | 2767 | ||
| 2768 | /* Extract parm names and values into those vectors. */ | 2768 | /* Extract parm names and values into those vectors. */ |
| 2769 | 2769 | ||
| @@ -3624,17 +3624,17 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li | |||
| 3624 | 3624 | ||
| 3625 | /* Allocate space for the components, the dots which separate them, | 3625 | /* Allocate space for the components, the dots which separate them, |
| 3626 | and the final '\0'. Make them big enough for the worst case. */ | 3626 | and the final '\0'. Make them big enough for the worst case. */ |
| 3627 | name_key = (char *) alloca (SBYTES (Vx_resource_name) | 3627 | name_key = alloca (SBYTES (Vx_resource_name) |
| 3628 | + (STRINGP (component) | 3628 | + (STRINGP (component) |
| 3629 | ? SBYTES (component) : 0) | 3629 | ? SBYTES (component) : 0) |
| 3630 | + SBYTES (attribute) | 3630 | + SBYTES (attribute) |
| 3631 | + 3); | 3631 | + 3); |
| 3632 | 3632 | ||
| 3633 | class_key = (char *) alloca (SBYTES (Vx_resource_class) | 3633 | class_key = alloca (SBYTES (Vx_resource_class) |
| 3634 | + SBYTES (class) | 3634 | + SBYTES (class) |
| 3635 | + (STRINGP (subclass) | 3635 | + (STRINGP (subclass) |
| 3636 | ? SBYTES (subclass) : 0) | 3636 | ? SBYTES (subclass) : 0) |
| 3637 | + 3); | 3637 | + 3); |
| 3638 | 3638 | ||
| 3639 | /* Start with emacs.FRAMENAME for the name (the specific one) | 3639 | /* Start with emacs.FRAMENAME for the name (the specific one) |
| 3640 | and with `Emacs' for the class key (the general one). */ | 3640 | and with `Emacs' for the class key (the general one). */ |
| @@ -3710,8 +3710,7 @@ x_get_resource_string (const char *attribute, const char *class) | |||
| 3710 | /* Allocate space for the components, the dots which separate them, | 3710 | /* Allocate space for the components, the dots which separate them, |
| 3711 | and the final '\0'. */ | 3711 | and the final '\0'. */ |
| 3712 | SAFE_ALLOCA (name_key, char *, invocation_namelen + strlen (attribute) + 2); | 3712 | SAFE_ALLOCA (name_key, char *, invocation_namelen + strlen (attribute) + 2); |
| 3713 | class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) | 3713 | class_key = alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2); |
| 3714 | + strlen (class) + 2); | ||
| 3715 | 3714 | ||
| 3716 | esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); | 3715 | esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); |
| 3717 | sprintf (class_key, "%s.%s", EMACS_CLASS, class); | 3716 | sprintf (class_key, "%s.%s", EMACS_CLASS, class); |