Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/include/linux Add kstrndup.
details: https://anonhg.NetBSD.org/src/rev/eff5e8b4907e
branches: trunk
changeset: 336317:eff5e8b4907e
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Feb 25 14:55:57 2015 +0000
description:
Add kstrndup.
diffstat:
sys/external/bsd/drm2/include/linux/string.h | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diffs (34 lines):
diff -r 3fe2ff2656a1 -r eff5e8b4907e sys/external/bsd/drm2/include/linux/string.h
--- a/sys/external/bsd/drm2/include/linux/string.h Wed Feb 25 14:51:22 2015 +0000
+++ b/sys/external/bsd/drm2/include/linux/string.h Wed Feb 25 14:55:57 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: string.h,v 1.3 2014/07/16 20:56:25 riastradh Exp $ */
+/* $NetBSD: string.h,v 1.4 2015/02/25 14:55:57 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -64,4 +64,24 @@
return dst;
}
+static inline char *
+kstrndup(const char *src, size_t maxlen, gfp_t gfp)
+{
+ char *dst;
+ size_t len;
+
+ if (src == NULL)
+ return NULL;
+
+ len = strnlen(src, maxlen);
+ dst = kmalloc(len + 1, gfp);
+ if (dst == NULL)
+ return NULL;
+
+ (void)memcpy(dst, src, len);
+ dst[len] = '\0';
+
+ return dst;
+}
+
#endif /* _LINUX_STRING_H_ */
Home |
Main Index |
Thread Index |
Old Index