diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-12-20 17:04:38 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-12-20 17:04:38 +0100 |
commit | 6ad50a1799e23a074e0fe39f3138ec3c9fd2445e (patch) | |
tree | 7393e3c29e0abd0f73aba7754416b94dcadec346 | |
parent | 1e7773d2bb5a0be8b0bc0562444562aaf8a3f801 (diff) | |
download | hda-emu-6ad50a1799e23a074e0fe39f3138ec3c9fd2445e.tar.gz |
Add the proper definition of strlcat()
Copied from the kernel code.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | include/wrapper.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/include/wrapper.h b/include/wrapper.h index b47f37f..67387e5 100644 --- a/include/wrapper.h +++ b/include/wrapper.h @@ -182,10 +182,19 @@ static inline int strict_strtol(const char *str, unsigned int base, long *val) return 0; } -/* XXX: this is just a workaround */ -static inline char *strlcat(char *dst, const char *src, size_t n) +static inline size_t strlcat(char *dest, const char *src, size_t count) { - return strncat(dst, src, n); + size_t dsize = strlen(dest); + size_t len = strlen(src); + size_t res = dsize + len; + + dest += dsize; + count -= dsize; + if (len >= count) + len = count-1; + memcpy(dest, src, len); + dest[len] = 0; + return res; } #ifdef DEBUG_MALLOC |