diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-02-03 16:11:28 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-02-03 16:11:28 +0100 |
commit | dddd0e7b0317f02e1aad5d60d87844da8f6785e4 (patch) | |
tree | 630de21b0f7b62a9afcd6380b606cd87ff6fe2ec /LibC/string.cpp | |
parent | 3944c00f23f023adabb71a53d1d25b8948b7482d (diff) | |
download | serenity-dddd0e7b0317f02e1aad5d60d87844da8f6785e4.zip |
Get nyancat nyanning in Serenity.
I found a cute program that renders an animated nyancat in the terminal.
This patch adds enough hackery to get it working correctly. :^)
Diffstat (limited to 'LibC/string.cpp')
-rw-r--r-- | LibC/string.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/LibC/string.cpp b/LibC/string.cpp index 02d8d934ea..47ddf45e3f 100644 --- a/LibC/string.cpp +++ b/LibC/string.cpp @@ -5,6 +5,7 @@ #include <assert.h> #include <stdlib.h> #include <AK/Types.h> +#include <AK/StdLibExtras.h> extern "C" { @@ -60,6 +61,15 @@ char* strdup(const char* str) return new_str; } +char* strndup(const char* str, size_t maxlen) +{ + size_t len = min(strlen(str), maxlen); + char* new_str = (char*)malloc(len + 1); + memcpy(new_str, str, len); + new_str[len] = 0; + return new_str; +} + int strcmp(const char* s1, const char* s2) { while (*s1 == *s2++) |