diff --git a/include/xfuncs.h b/include/xfuncs.h index 6431f0879..4ce4e9292 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 426484be2..01a64cf5e 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); +