Module: xenomai-3
Branch: master
Commit: e7585233e24a089b204230d6f3cc9d4b3a4f3ea1
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e7585233e24a089b204230d6f3cc9d4b3a4f3ea1

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Oct 27 11:14:11 2014 +0100

cobalt/heap: add xnstrdup()

---

 include/cobalt/kernel/heap.h |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/cobalt/kernel/heap.h b/include/cobalt/kernel/heap.h
index d29778f..916ac8f 100644
--- a/include/cobalt/kernel/heap.h
+++ b/include/cobalt/kernel/heap.h
@@ -19,6 +19,7 @@
 #ifndef _COBALT_KERNEL_HEAP_H
 #define _COBALT_KERNEL_HEAP_H
 
+#include <linux/string.h>
 #include <cobalt/kernel/lock.h>
 #include <cobalt/kernel/list.h>
 #include <cobalt/uapi/kernel/types.h>
@@ -142,6 +143,17 @@ void xnheap_free(struct xnheap *heap, void *block);
 
 int xnheap_check_block(struct xnheap *heap, void *block);
 
+static inline char *xnstrdup(const char *s)
+{
+       char *p;
+
+       p = xnmalloc(strlen(s) + 1);
+       if (p == NULL)
+               return NULL;
+
+       return strcpy(p, s);
+}
+
 /** @} */
 
 #endif /* !_COBALT_KERNEL_HEAP_H */


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to