aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
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/alloc.c
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/alloc.c')
-rw-r--r--src/alloc.c4
1 files changed, 3 insertions, 1 deletions
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