aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2013-08-10 08:42:08 -0700
committerPaul Eggert2013-08-10 08:42:08 -0700
commit9acc107445a159001e56bae04ef2dc2792aa16d7 (patch)
treec96ba4d408258a0addfbe97e602c2aa5148dfcd2 /src
parent45fdb48240996f7ad9c8c03f438ecf7f5b925d8e (diff)
downloademacs-9acc107445a159001e56bae04ef2dc2792aa16d7.tar.gz
emacs-9acc107445a159001e56bae04ef2dc2792aa16d7.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/alloc.c4
-rw-r--r--src/frame.c5
3 files changed, 12 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f1293be9855..976d068dadc 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12013-08-10 Paul Eggert <eggert@cs.ucla.edu>
2
3 Minor string-length refactoring.
4 * alloc.c (xstrdup): Use memcpy, not strcpy, since the length's known.
5 * frame.c (make_monitor_attribute_list):
6 Prefer build_string to strlen + make_string.
7
12013-08-10 Jan Djärv <jan.h.d@swipnet.se> 82013-08-10 Jan Djärv <jan.h.d@swipnet.se>
2 9
3 * xterm.c (x_error_handler): Also ignore BadWindow for X_SetInputFocus, 10 * xterm.c (x_error_handler): Also ignore BadWindow for X_SetInputFocus,
diff --git a/src/alloc.c b/src/alloc.c
index 19418bd6686..f9bcaed0117 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -796,8 +796,10 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min,
796char * 796char *
797xstrdup (const char *s) 797xstrdup (const char *s)
798{ 798{
799 ptrdiff_t size;
799 eassert (s); 800 eassert (s);
800 return strcpy (xmalloc (strlen (s) + 1), s); 801 size = strlen (s) + 1;
802 return memcpy (xmalloc (size), s, size);
801} 803}
802 804
803/* Like putenv, but (1) use the equivalent of xmalloc and (2) the 805/* Like putenv, but (1) use the equivalent of xmalloc and (2) the
diff --git a/src/frame.c b/src/frame.c
index 853ec441343..9989ef7af13 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -725,7 +725,7 @@ affects all frames on the same terminal device. */)
725 XSETFRAME (frame, f); 725 XSETFRAME (frame, f);
726 726
727 store_in_alist (&parms, Qtty_type, build_string (t->display_info.tty->type)); 727 store_in_alist (&parms, Qtty_type, build_string (t->display_info.tty->type));
728 store_in_alist (&parms, Qtty, 728 store_in_alist (&parms, Qtty,
729 (t->display_info.tty->name 729 (t->display_info.tty->name
730 ? build_string (t->display_info.tty->name) 730 ? build_string (t->display_info.tty->name)
731 : Qnil)); 731 : Qnil));
@@ -4203,8 +4203,7 @@ make_monitor_attribute_list (struct MonitorInfo *monitors,
4203 mi->work.width, mi->work.height); 4203 mi->work.width, mi->work.height);
4204 geometry = list4i (mi->geom.x, mi->geom.y, 4204 geometry = list4i (mi->geom.x, mi->geom.y,
4205 mi->geom.width, mi->geom.height); 4205 mi->geom.width, mi->geom.height);
4206 attributes = Fcons (Fcons (Qsource, 4206 attributes = Fcons (Fcons (Qsource, build_string (source)),
4207 make_string (source, strlen (source))),
4208 attributes); 4207 attributes);
4209 attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)), 4208 attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
4210 attributes); 4209 attributes);