diff options
-rw-r--r-- | include/xfuncs.h | 1 | ||||
-rw-r--r-- | lib/xfuncs.c | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/include/xfuncs.h b/include/xfuncs.h index 6431f08790..4ce4e92928 100644 --- a/include/xfuncs.h +++ b/include/xfuncs.h @@ -4,5 +4,6 @@ void *xmalloc(size_t size); void *xrealloc(void *ptr, size_t size); void *xzalloc(size_t size); +char *xstrdup(const char *s); #endif /* __XFUNCS_H */ diff --git a/lib/xfuncs.c b/lib/xfuncs.c index 426484be28..01a64cf5eb 100644 --- a/lib/xfuncs.c +++ b/lib/xfuncs.c @@ -60,3 +60,13 @@ void *xzalloc(size_t size) } EXPORT_SYMBOL(xzalloc); +char *xstrdup(const char *s) +{ + char *p = strdup(s); + + if (!p) + panic("ERROR: out of memory\n"); + return p; +} +EXPORT_SYMBOL(xstrdup); + |