aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-03-20 12:05:58 +0100
committerTakashi Iwai <tiwai@suse.de>2015-03-20 12:05:58 +0100
commit4fdccf0f77ddee9507f5981eaf69647e46820687 (patch)
tree2776a89999718dacb1734f5ff0532cf23b9b3c5d
parent2fc911527eb2a9ca27a7d0bfd6e2e715541d09ed (diff)
downloadhda-emu-4fdccf0f77ddee9507f5981eaf69647e46820687.tar.gz
Add more helper string functions
- kstrtoint() (incomplete, no error check) - kasprintf() Also fix the malloc call in kvasprintf() to use the our own helper. Otherwise it'll screw up at freeing this memory.
-rw-r--r--include/wrapper.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/include/wrapper.h b/include/wrapper.h
index c5bbc2f..685f729 100644
--- a/include/wrapper.h
+++ b/include/wrapper.h
@@ -202,6 +202,12 @@ static inline int strict_strtol(const char *str, unsigned int base, long *val)
return 0;
}
+static inline int kstrtoint(const char *s, unsigned int base, int *res)
+{
+ *res = strtol(s, NULL, base);
+ return 0;
+}
+
static inline size_t strlcat(char *dest, const char *src, size_t count)
{
size_t dsize = strlen(dest);
@@ -281,13 +287,24 @@ static inline char *kvasprintf(int gfp, const char *fmt, va_list ap)
va_end(app);
if (len < 0)
return NULL;
- buf = malloc(len + 1);
+ buf = __hda_malloc(len + 1, __FILE__, __LINE__, 0);
if (!buf)
return NULL;
vsnprintf(buf, len + 1, fmt, ap);
return buf;
}
+static inline char *kasprintf(int gfp, const char *fmt, ...)
+{
+ va_list ap;
+ char *ret;
+
+ va_start(ap, fmt);
+ ret = kvasprintf(gfp, fmt, ap);
+ va_end(ap);
+ return ret;
+}
+
#define KBUILD_MODNAME __FILE__
#define module_driver(__driver, __register, __unregister, ...) \