summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2009-02-28 05:15:02 +0000
committerdas <das@FreeBSD.org>2009-02-28 05:15:02 +0000
commit28465baaf036b1850892b050b1d72364f8804009 (patch)
tree7e902fb5273a6c2db8f3abbe37e146d679621875
parentd6bc3f67e875e9575c6f759df2a0b47a8996ca68 (diff)
downloadFreeBSD-src-28465baaf036b1850892b050b1d72364f8804009.zip
FreeBSD-src-28465baaf036b1850892b050b1d72364f8804009.tar.gz
Add restrict qualifiers to the parameters to strlcpy() and strlcat().
The annotation mainly just serves as a hint that they're not intended for use with overlapping strings.
-rw-r--r--include/string.h4
-rw-r--r--lib/libc/string/strlcat.c2
-rw-r--r--lib/libc/string/strlcpy.34
-rw-r--r--lib/libc/string/strlcpy.c2
4 files changed, 6 insertions, 6 deletions
diff --git a/include/string.h b/include/string.h
index 75e8558..91007f1 100644
--- a/include/string.h
+++ b/include/string.h
@@ -85,8 +85,8 @@ char *strerror(int);
int strerror_r(int, char *, size_t);
#endif
#if __BSD_VISIBLE
-size_t strlcat(char *, const char *, size_t);
-size_t strlcpy(char *, const char *, size_t);
+size_t strlcat(char * __restrict, const char * __restrict, size_t);
+size_t strlcpy(char * __restrict, const char * __restrict, size_t);
#endif
size_t strlen(const char *) __pure;
#if __BSD_VISIBLE
diff --git a/lib/libc/string/strlcat.c b/lib/libc/string/strlcat.c
index feeac3b..2d13be7 100644
--- a/lib/libc/string/strlcat.c
+++ b/lib/libc/string/strlcat.c
@@ -30,7 +30,7 @@ __FBSDID("$FreeBSD$");
* If retval >= siz, truncation occurred.
*/
size_t
-strlcat(char *dst, const char *src, size_t siz)
+strlcat(char * __restrict dst, const char * __restrict src, size_t siz)
{
char *d = dst;
const char *s = src;
diff --git a/lib/libc/string/strlcpy.3 b/lib/libc/string/strlcpy.3
index 88af06d..aaef572 100644
--- a/lib/libc/string/strlcpy.3
+++ b/lib/libc/string/strlcpy.3
@@ -39,9 +39,9 @@
.Sh SYNOPSIS
.In string.h
.Ft size_t
-.Fn strlcpy "char *dst" "const char *src" "size_t size"
+.Fn strlcpy "char * restrict dst" "const char * restrict src" "size_t size"
.Ft size_t
-.Fn strlcat "char *dst" "const char *src" "size_t size"
+.Fn strlcat "char * restrict dst" "const char * restrict src" "size_t size"
.Sh DESCRIPTION
The
.Fn strlcpy
diff --git a/lib/libc/string/strlcpy.c b/lib/libc/string/strlcpy.c
index 187bdb7..451b6df 100644
--- a/lib/libc/string/strlcpy.c
+++ b/lib/libc/string/strlcpy.c
@@ -28,7 +28,7 @@ __FBSDID("$FreeBSD$");
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
size_t
-strlcpy(char *dst, const char *src, size_t siz)
+strlcpy(char * __restrict dst, const char * __restrict src, size_t siz)
{
char *d = dst;
const char *s = src;
OpenPOWER on IntegriCloud