|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH v2 02/10] lib/nolibc: Add strdup function
Hey, On 23.08.2018 12:59, Costin Lupu wrote: Shamelessly taken from Mini-OS. Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx> --- lib/nolibc/include/string.h | 1 + lib/nolibc/string.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/nolibc/include/string.h b/lib/nolibc/include/string.h index 677f528..8674c77 100644 --- a/lib/nolibc/include/string.h +++ b/lib/nolibc/include/string.h @@ -57,6 +57,7 @@ size_t strlen(const char *str); const char *strchr(const char *str, int c); int strncmp(const char *str1, const char *str2, size_t len); int strcmp(const char *str1, const char *str2); +char *strdup(const char *str);#ifdef __cplusplus} diff --git a/lib/nolibc/string.c b/lib/nolibc/string.c index bf89106..bf4ab50 100644 --- a/lib/nolibc/string.c +++ b/lib/nolibc/string.c @@ -33,6 +33,7 @@ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY. */+#include <stdlib.h>#include <stdint.h> #include <string.h> #include <limits.h> @@ -166,3 +167,19 @@ int strcmp(const char *str1, const char *str2)return __res; Could you provide an strndup() instead and make strdup() use it? This way we would cover both libc variants with one patch.
I mean, you would do something like:
char *strdup(const char *str)
{
return strndup(str, SIZE_MAX);
}
Cheers,
Simon
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |