Commit 309f24d1 authored by Dmitry Antipov's avatar Dmitry Antipov

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.
parent 55902276
2013-08-09 Dmitry Antipov <dmantipov@yandex.ru>
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.
2013-08-09 Eli Zaretskii <eliz@gnu.org>
* w32.c (PEXCEPTION_POINTERS, PEXCEPTION_RECORD, PCONTEXT): Define
......
......@@ -796,10 +796,8 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min,
char *
xstrdup (const char *s)
{
size_t len = strlen (s) + 1;
char *p = xmalloc (len);
memcpy (p, s, len);
return p;
eassert (s);
return strcpy (xmalloc (strlen (s) + 1), s);
}
/* Like putenv, but (1) use the equivalent of xmalloc and (2) the
......
......@@ -517,8 +517,7 @@ init_cmdargs (int argc, char **argv, int skip_args)
They are decoded in the function command-line after we know
locale-coding-system. */
Vcommand_line_args
= Fcons (make_unibyte_string (argv[i], strlen (argv[i])),
Vcommand_line_args);
= Fcons (build_unibyte_string (argv[i]), Vcommand_line_args);
}
unbind_to (count, Qnil);
......
......@@ -8431,7 +8431,7 @@ read_char_minibuf_menu_prompt (int commandflag,
return Qnil;
#define PUSH_C_STR(str, listvar) \
listvar = Fcons (make_unibyte_string (str, strlen (str)), listvar)
listvar = Fcons (build_unibyte_string (str), listvar)
/* Prompt string always starts with map's prompt, and a space. */
prompt_strings = Fcons (name, prompt_strings);
......
......@@ -920,8 +920,7 @@ when setting family in ns_spec_to_descriptor(). */
font->underline_thickness = lrint (font_info->underwidth);
font->props[FONT_NAME_INDEX] = Ffont_xlfd_name (font_object, Qnil);
font->props[FONT_FULLNAME_INDEX] =
make_unibyte_string (font_info->name, strlen (font_info->name));
font->props[FONT_FULLNAME_INDEX] = build_unibyte_string (font_info->name);
}
unblock_input ();
......
......@@ -3243,13 +3243,11 @@ system_process_attributes (Lisp_Object pid)
attrs);
decoded_cmd = (code_convert_string_norecord
(make_unibyte_string (pinfo.pr_fname,
strlen (pinfo.pr_fname)),
(build_unibyte_string (pinfo.pr_fname),
Vlocale_coding_system, 0));
attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs);
decoded_cmd = (code_convert_string_norecord
(make_unibyte_string (pinfo.pr_psargs,
strlen (pinfo.pr_psargs)),
(build_unibyte_string (pinfo.pr_psargs),
Vlocale_coding_system, 0));
attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs);
}
......@@ -3319,9 +3317,9 @@ system_process_attributes (Lisp_Object pid)
if (gr)
attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
decoded_comm = code_convert_string_norecord
(make_unibyte_string (proc.ki_comm, strlen (proc.ki_comm)),
Vlocale_coding_system, 0);
decoded_comm = (code_convert_string_norecord
(build_unibyte_string (proc.ki_comm),
Vlocale_coding_system, 0));
attrs = Fcons (Fcons (Qcomm, decoded_comm), attrs);
{
......
......@@ -5769,8 +5769,8 @@ system_process_attributes (Lisp_Object pid)
{
/* Decode the command name from locale-specific
encoding. */
cmd_str = make_unibyte_string (pe.szExeFile,
strlen (pe.szExeFile));
cmd_str = build_unibyte_string (pe.szExeFile);
decoded_cmd =
code_convert_string_norecord (cmd_str,
Vlocale_coding_system, 0);
......
......@@ -4124,12 +4124,7 @@ w32_window (struct frame *f, long window_prompting, int minibuffer_only)
for the window manager, so GC relocation won't bother it.
Elsewhere we specify the window name for the window manager. */
{
char *str = SSDATA (Vx_resource_name);
f->namebuf = xmalloc (strlen (str) + 1);
strcpy (f->namebuf, str);
}
f->namebuf = xstrdup (SSDATA (Vx_resource_name));
my_create_window (f);
......@@ -4992,8 +4987,8 @@ w32_display_monitor_attributes_list (void)
attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
attributes);
name = DECODE_SYSTEM (make_unibyte_string (mi.szDevice,
strlen (mi.szDevice)));
name = DECODE_SYSTEM (build_unibyte_string (mi.szDevice));
attributes = Fcons (Fcons (Qname, name), attributes);
attributes = Fcons (Fcons (Qmm_size, list2i (width_mm, height_mm)),
......
......@@ -9789,7 +9789,7 @@ message3_nolog (Lisp_Object m)
void
message1 (const char *m)
{
message3 (m ? make_unibyte_string (m, strlen (m)) : Qnil);
message3 (m ? build_unibyte_string (m) : Qnil);
}
......@@ -9798,7 +9798,7 @@ message1 (const char *m)
void
message1_nolog (const char *m)
{
message3_nolog (m ? make_unibyte_string (m, strlen (m)) : Qnil);
message3_nolog (m ? build_unibyte_string (m) : Qnil);
}
/* Display a message M which contains a single %s
......
......@@ -2313,12 +2313,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
for the window manager, so GC relocation won't bother it.
Elsewhere we specify the window name for the window manager. */
{
char *str = SSDATA (Vx_resource_name);
f->namebuf = xmalloc (strlen (str) + 1);
strcpy (f->namebuf, str);
}
f->namebuf = xstrdup (SSDATA (Vx_resource_name));
ac = 0;
XtSetArg (al[ac], XtNallowShellResize, 1); ac++;
......
......@@ -75,18 +75,9 @@ x_get_customization_string (XrmDatabase db, const char *name,
sprintf (full_class, "%s.%s", class, "Customization");
result = x_get_string_resource (db, full_name, full_class);
if (result)
{
char *copy = xmalloc (strlen (result) + 1);
strcpy (copy, result);
return copy;
}
else
return 0;
return result ? xstrdup (result) : NULL;
}
/* Expand all the Xt-style %-escapes in STRING, whose length is given
by STRING_LEN. Here are the escapes we're supposed to recognize:
......
......@@ -8081,13 +8081,10 @@ xim_initialize (struct x_display_info *dpyinfo, char *resource_name)
{
#ifdef HAVE_X11R6_XIM
struct xim_inst_t *xim_inst = xmalloc (sizeof *xim_inst);
ptrdiff_t len;
dpyinfo->xim_callback_data = xim_inst;
xim_inst->dpyinfo = dpyinfo;
len = strlen (resource_name);
xim_inst->resource_name = xmalloc (len + 1);
memcpy (xim_inst->resource_name, resource_name, len + 1);
xim_inst->resource_name = xstrdup (resource_name);
XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
resource_name, emacs_class,
xim_instantiate_callback,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment