+2013-08-10 Paul Eggert <eggert@cs.ucla.edu>
+
+ Minor string-length refactoring.
+ * alloc.c (xstrdup): Use memcpy, not strcpy, since the length's known.
+ * frame.c (make_monitor_attribute_list):
+ Prefer build_string to strlen + make_string.
+
2013-08-10 Jan Djärv <jan.h.d@swipnet.se>
* xterm.c (x_error_handler): Also ignore BadWindow for X_SetInputFocus,
char *
xstrdup (const char *s)
{
+ ptrdiff_t size;
eassert (s);
- return strcpy (xmalloc (strlen (s) + 1), s);
+ size = strlen (s) + 1;
+ return memcpy (xmalloc (size), s, size);
}
/* Like putenv, but (1) use the equivalent of xmalloc and (2) the
XSETFRAME (frame, f);
store_in_alist (&parms, Qtty_type, build_string (t->display_info.tty->type));
- store_in_alist (&parms, Qtty,
+ store_in_alist (&parms, Qtty,
(t->display_info.tty->name
? build_string (t->display_info.tty->name)
: Qnil));
mi->work.width, mi->work.height);
geometry = list4i (mi->geom.x, mi->geom.y,
mi->geom.width, mi->geom.height);
- attributes = Fcons (Fcons (Qsource,
- make_string (source, strlen (source))),
+ attributes = Fcons (Fcons (Qsource, build_string (source)),
attributes);
attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
attributes);