aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/string.c
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2005-01-14 08:35:24 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2005-01-14 08:35:24 +0000
commit2047f7809acfbfbe8627fff1feca9788f2c27267 (patch)
tree34bb9c989a07553afba1ffab4bb5a7fc0678e8d9 /xen/common/string.c
parente214e5c6c11ea61a9e256574b50dcab5852d62c0 (diff)
downloadxen-2047f7809acfbfbe8627fff1feca9788f2c27267.tar.gz
xen-2047f7809acfbfbe8627fff1feca9788f2c27267.tar.bz2
xen-2047f7809acfbfbe8627fff1feca9788f2c27267.zip
bitkeeper revision 1.1159.170.94 (41e7844cyG1BmL1dUF848HyZ7mu87A)
Tweaks from Dan Magenheimer.
Diffstat (limited to 'xen/common/string.c')
-rw-r--r--xen/common/string.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/xen/common/string.c b/xen/common/string.c
index c49d32deb0..1f51b65ecb 100644
--- a/xen/common/string.c
+++ b/xen/common/string.c
@@ -92,6 +92,32 @@ char * strncpy(char * dest,const char *src,size_t count)
}
#endif
+#ifndef __HAVE_ARCH_STRLCPY
+/**
+ * strlcpy - Copy a %NUL terminated string into a sized buffer
+ * @dest: Where to copy the string to
+ * @src: Where to copy the string from
+ * @size: size of destination buffer
+ *
+ * Compatible with *BSD: the result is always a valid
+ * NUL-terminated string that fits in the buffer (unless,
+ * of course, the buffer size is zero). It does not pad
+ * out the result like strncpy() does.
+ */
+size_t strlcpy(char *dest, const char *src, size_t size)
+{
+ size_t ret = strlen(src);
+
+ if (size) {
+ size_t len = (ret >= size) ? size-1 : ret;
+ memcpy(dest, src, len);
+ dest[len] = '\0';
+ }
+ return ret;
+}
+EXPORT_SYMBOL(strlcpy);
+#endif
+
#ifndef __HAVE_ARCH_STRCAT
/**
* strcat - Append one %NUL-terminated string to another
@@ -449,7 +475,6 @@ void * memmove(void * dest,const void *src,size_t count)
* @ct: Another area of memory
* @count: The size of the area.
*/
-/*
int memcmp(const void * cs,const void * ct,size_t count)
{
const unsigned char *su1, *su2;
@@ -460,7 +485,6 @@ int memcmp(const void * cs,const void * ct,size_t count)
break;
return res;
}
-*/
#endif
#ifndef __HAVE_ARCH_MEMSCAN