aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2013-08-09 16:25:34 +0400
committerDmitry Antipov2013-08-09 16:25:34 +0400
commit309f24d1ec07646fb1a090ee10fe456e79aea097 (patch)
tree19ba0104e3713ee963113a52f9b38107a3740b2a /src
parent55902276706ea2db832ad5748a18ab392a0873f1 (diff)
downloademacs-309f24d1ec07646fb1a090ee10fe456e79aea097.tar.gz
emacs-309f24d1ec07646fb1a090ee10fe456e79aea097.zip
Use xstrdup and build_unibyte_string where applicable.
* alloc.c (xstrdup): Tiny cleanup. Add eassert. * xfns.c (x_window): * xrdb.c (x_get_customization_string): * xterm.c (xim_initialize): * w32fns.c (w32_window): Use xstrdup. (w32_display_monitor_attributes_list): * emacs.c (init_cmdargs): * keyboard.c (PUSH_C_STR): * nsfont.m (nsfont_open): * sysdep.c (system_process_attributes): * w32.c (system_process_attributes): * xdisp.c (message1, message1_nolog): Use build_unibyte_string.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog16
-rw-r--r--src/alloc.c6
-rw-r--r--src/emacs.c3
-rw-r--r--src/keyboard.c2
-rw-r--r--src/nsfont.m3
-rw-r--r--src/sysdep.c12
-rw-r--r--src/w32.c4
-rw-r--r--src/w32fns.c11
-rw-r--r--src/xdisp.c4
-rw-r--r--src/xfns.c7
-rw-r--r--src/xrdb.c11
-rw-r--r--src/xterm.c5
12 files changed, 36 insertions, 48 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index aa424d2ec06..bd8aae80d5d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,19 @@
12013-08-09 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Use xstrdup and build_unibyte_string where applicable.
4 * alloc.c (xstrdup): Tiny cleanup. Add eassert.
5 * xfns.c (x_window):
6 * xrdb.c (x_get_customization_string):
7 * xterm.c (xim_initialize):
8 * w32fns.c (w32_window): Use xstrdup.
9 (w32_display_monitor_attributes_list):
10 * emacs.c (init_cmdargs):
11 * keyboard.c (PUSH_C_STR):
12 * nsfont.m (nsfont_open):
13 * sysdep.c (system_process_attributes):
14 * w32.c (system_process_attributes):
15 * xdisp.c (message1, message1_nolog): Use build_unibyte_string.
16
12013-08-09 Eli Zaretskii <eliz@gnu.org> 172013-08-09 Eli Zaretskii <eliz@gnu.org>
2 18
3 * w32.c (PEXCEPTION_POINTERS, PEXCEPTION_RECORD, PCONTEXT): Define 19 * w32.c (PEXCEPTION_POINTERS, PEXCEPTION_RECORD, PCONTEXT): Define
diff --git a/src/alloc.c b/src/alloc.c
index c8141d22f95..19418bd6686 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -796,10 +796,8 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min,
796char * 796char *
797xstrdup (const char *s) 797xstrdup (const char *s)
798{ 798{
799 size_t len = strlen (s) + 1; 799 eassert (s);
800 char *p = xmalloc (len); 800 return strcpy (xmalloc (strlen (s) + 1), s);
801 memcpy (p, s, len);
802 return p;
803} 801}
804 802
805/* Like putenv, but (1) use the equivalent of xmalloc and (2) the 803/* Like putenv, but (1) use the equivalent of xmalloc and (2) the
diff --git a/src/emacs.c b/src/emacs.c
index cf3a3c68932..23aef6a2b65 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -517,8 +517,7 @@ init_cmdargs (int argc, char **argv, int skip_args)
517 They are decoded in the function command-line after we know 517 They are decoded in the function command-line after we know
518 locale-coding-system. */ 518 locale-coding-system. */
519 Vcommand_line_args 519 Vcommand_line_args
520 = Fcons (make_unibyte_string (argv[i], strlen (argv[i])), 520 = Fcons (build_unibyte_string (argv[i]), Vcommand_line_args);
521 Vcommand_line_args);
522 } 521 }
523 522
524 unbind_to (count, Qnil); 523 unbind_to (count, Qnil);
diff --git a/src/keyboard.c b/src/keyboard.c
index c026b16e689..3afdce42ca2 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -8431,7 +8431,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8431 return Qnil; 8431 return Qnil;
8432 8432
8433#define PUSH_C_STR(str, listvar) \ 8433#define PUSH_C_STR(str, listvar) \
8434 listvar = Fcons (make_unibyte_string (str, strlen (str)), listvar) 8434 listvar = Fcons (build_unibyte_string (str), listvar)
8435 8435
8436 /* Prompt string always starts with map's prompt, and a space. */ 8436 /* Prompt string always starts with map's prompt, and a space. */
8437 prompt_strings = Fcons (name, prompt_strings); 8437 prompt_strings = Fcons (name, prompt_strings);
diff --git a/src/nsfont.m b/src/nsfont.m
index ad169d7ddae..235150e3aef 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -920,8 +920,7 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size)
920 font->underline_thickness = lrint (font_info->underwidth); 920 font->underline_thickness = lrint (font_info->underwidth);
921 921
922 font->props[FONT_NAME_INDEX] = Ffont_xlfd_name (font_object, Qnil); 922 font->props[FONT_NAME_INDEX] = Ffont_xlfd_name (font_object, Qnil);
923 font->props[FONT_FULLNAME_INDEX] = 923 font->props[FONT_FULLNAME_INDEX] = build_unibyte_string (font_info->name);
924 make_unibyte_string (font_info->name, strlen (font_info->name));
925 } 924 }
926 unblock_input (); 925 unblock_input ();
927 926
diff --git a/src/sysdep.c b/src/sysdep.c
index 11a6f4a76ce..201ba9d104d 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -3243,13 +3243,11 @@ system_process_attributes (Lisp_Object pid)
3243 attrs); 3243 attrs);
3244 3244
3245 decoded_cmd = (code_convert_string_norecord 3245 decoded_cmd = (code_convert_string_norecord
3246 (make_unibyte_string (pinfo.pr_fname, 3246 (build_unibyte_string (pinfo.pr_fname),
3247 strlen (pinfo.pr_fname)),
3248 Vlocale_coding_system, 0)); 3247 Vlocale_coding_system, 0));
3249 attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs); 3248 attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs);
3250 decoded_cmd = (code_convert_string_norecord 3249 decoded_cmd = (code_convert_string_norecord
3251 (make_unibyte_string (pinfo.pr_psargs, 3250 (build_unibyte_string (pinfo.pr_psargs),
3252 strlen (pinfo.pr_psargs)),
3253 Vlocale_coding_system, 0)); 3251 Vlocale_coding_system, 0));
3254 attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs); 3252 attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs);
3255 } 3253 }
@@ -3319,9 +3317,9 @@ system_process_attributes (Lisp_Object pid)
3319 if (gr) 3317 if (gr)
3320 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs); 3318 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
3321 3319
3322 decoded_comm = code_convert_string_norecord 3320 decoded_comm = (code_convert_string_norecord
3323 (make_unibyte_string (proc.ki_comm, strlen (proc.ki_comm)), 3321 (build_unibyte_string (proc.ki_comm),
3324 Vlocale_coding_system, 0); 3322 Vlocale_coding_system, 0));
3325 3323
3326 attrs = Fcons (Fcons (Qcomm, decoded_comm), attrs); 3324 attrs = Fcons (Fcons (Qcomm, decoded_comm), attrs);
3327 { 3325 {
diff --git a/src/w32.c b/src/w32.c
index 9b87cfc8faa..21dbf49ed7c 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -5769,8 +5769,8 @@ system_process_attributes (Lisp_Object pid)
5769 { 5769 {
5770 /* Decode the command name from locale-specific 5770 /* Decode the command name from locale-specific
5771 encoding. */ 5771 encoding. */
5772 cmd_str = make_unibyte_string (pe.szExeFile, 5772 cmd_str = build_unibyte_string (pe.szExeFile);
5773 strlen (pe.szExeFile)); 5773
5774 decoded_cmd = 5774 decoded_cmd =
5775 code_convert_string_norecord (cmd_str, 5775 code_convert_string_norecord (cmd_str,
5776 Vlocale_coding_system, 0); 5776 Vlocale_coding_system, 0);
diff --git a/src/w32fns.c b/src/w32fns.c
index dff35de0973..c43b7d4adf3 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -4124,12 +4124,7 @@ w32_window (struct frame *f, long window_prompting, int minibuffer_only)
4124 for the window manager, so GC relocation won't bother it. 4124 for the window manager, so GC relocation won't bother it.
4125 4125
4126 Elsewhere we specify the window name for the window manager. */ 4126 Elsewhere we specify the window name for the window manager. */
4127 4127 f->namebuf = xstrdup (SSDATA (Vx_resource_name));
4128 {
4129 char *str = SSDATA (Vx_resource_name);
4130 f->namebuf = xmalloc (strlen (str) + 1);
4131 strcpy (f->namebuf, str);
4132 }
4133 4128
4134 my_create_window (f); 4129 my_create_window (f);
4135 4130
@@ -4992,8 +4987,8 @@ w32_display_monitor_attributes_list (void)
4992 attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)), 4987 attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
4993 attributes); 4988 attributes);
4994 4989
4995 name = DECODE_SYSTEM (make_unibyte_string (mi.szDevice, 4990 name = DECODE_SYSTEM (build_unibyte_string (mi.szDevice));
4996 strlen (mi.szDevice))); 4991
4997 attributes = Fcons (Fcons (Qname, name), attributes); 4992 attributes = Fcons (Fcons (Qname, name), attributes);
4998 4993
4999 attributes = Fcons (Fcons (Qmm_size, list2i (width_mm, height_mm)), 4994 attributes = Fcons (Fcons (Qmm_size, list2i (width_mm, height_mm)),
diff --git a/src/xdisp.c b/src/xdisp.c
index ab625b9d6ec..aee24e27d52 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -9789,7 +9789,7 @@ message3_nolog (Lisp_Object m)
9789void 9789void
9790message1 (const char *m) 9790message1 (const char *m)
9791{ 9791{
9792 message3 (m ? make_unibyte_string (m, strlen (m)) : Qnil); 9792 message3 (m ? build_unibyte_string (m) : Qnil);
9793} 9793}
9794 9794
9795 9795
@@ -9798,7 +9798,7 @@ message1 (const char *m)
9798void 9798void
9799message1_nolog (const char *m) 9799message1_nolog (const char *m)
9800{ 9800{
9801 message3_nolog (m ? make_unibyte_string (m, strlen (m)) : Qnil); 9801 message3_nolog (m ? build_unibyte_string (m) : Qnil);
9802} 9802}
9803 9803
9804/* Display a message M which contains a single %s 9804/* Display a message M which contains a single %s
diff --git a/src/xfns.c b/src/xfns.c
index a1e9e916aba..92a7964eb75 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -2313,12 +2313,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
2313 for the window manager, so GC relocation won't bother it. 2313 for the window manager, so GC relocation won't bother it.
2314 2314
2315 Elsewhere we specify the window name for the window manager. */ 2315 Elsewhere we specify the window name for the window manager. */
2316 2316 f->namebuf = xstrdup (SSDATA (Vx_resource_name));
2317 {
2318 char *str = SSDATA (Vx_resource_name);
2319 f->namebuf = xmalloc (strlen (str) + 1);
2320 strcpy (f->namebuf, str);
2321 }
2322 2317
2323 ac = 0; 2318 ac = 0;
2324 XtSetArg (al[ac], XtNallowShellResize, 1); ac++; 2319 XtSetArg (al[ac], XtNallowShellResize, 1); ac++;
diff --git a/src/xrdb.c b/src/xrdb.c
index 7c9cd53fa8c..6ef5c3bcb41 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -75,18 +75,9 @@ x_get_customization_string (XrmDatabase db, const char *name,
75 sprintf (full_class, "%s.%s", class, "Customization"); 75 sprintf (full_class, "%s.%s", class, "Customization");
76 76
77 result = x_get_string_resource (db, full_name, full_class); 77 result = x_get_string_resource (db, full_name, full_class);
78 78 return result ? xstrdup (result) : NULL;
79 if (result)
80 {
81 char *copy = xmalloc (strlen (result) + 1);
82 strcpy (copy, result);
83 return copy;
84 }
85 else
86 return 0;
87} 79}
88 80
89
90/* Expand all the Xt-style %-escapes in STRING, whose length is given 81/* Expand all the Xt-style %-escapes in STRING, whose length is given
91 by STRING_LEN. Here are the escapes we're supposed to recognize: 82 by STRING_LEN. Here are the escapes we're supposed to recognize:
92 83
diff --git a/src/xterm.c b/src/xterm.c
index 6391154961f..db5ca1a1fbb 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8081,13 +8081,10 @@ xim_initialize (struct x_display_info *dpyinfo, char *resource_name)
8081 { 8081 {
8082#ifdef HAVE_X11R6_XIM 8082#ifdef HAVE_X11R6_XIM
8083 struct xim_inst_t *xim_inst = xmalloc (sizeof *xim_inst); 8083 struct xim_inst_t *xim_inst = xmalloc (sizeof *xim_inst);
8084 ptrdiff_t len;
8085 8084
8086 dpyinfo->xim_callback_data = xim_inst; 8085 dpyinfo->xim_callback_data = xim_inst;
8087 xim_inst->dpyinfo = dpyinfo; 8086 xim_inst->dpyinfo = dpyinfo;
8088 len = strlen (resource_name); 8087 xim_inst->resource_name = xstrdup (resource_name);
8089 xim_inst->resource_name = xmalloc (len + 1);
8090 memcpy (xim_inst->resource_name, resource_name, len + 1);
8091 XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, 8088 XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
8092 resource_name, emacs_class, 8089 resource_name, emacs_class,
8093 xim_instantiate_callback, 8090 xim_instantiate_callback,