summaryrefslogtreecommitdiff
path: root/userland/libc/string/strndup.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-12-12 16:03:08 +0100
committerAnton Kling <anton@kling.gg>2024-12-12 16:03:08 +0100
commitb033314bf1901d436dc71d41d5e1f37dda47e511 (patch)
tree120bd137888a7f96904a47af7d20422608ffe225 /userland/libc/string/strndup.c
parentdcbcdbdc5bcfb86eca05fb655e3bf009d89e39e0 (diff)
formatting: Use clang-format on all projects
This commit also add braces to all `if` statements.
Diffstat (limited to 'userland/libc/string/strndup.c')
-rw-r--r--userland/libc/string/strndup.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/userland/libc/string/strndup.c b/userland/libc/string/strndup.c
index 22d6303..3240d97 100644
--- a/userland/libc/string/strndup.c
+++ b/userland/libc/string/strndup.c
@@ -1,7 +1,7 @@
+#include <math.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <math.h>
// The strndup() function shall be equivalent to the strdup() function,
// duplicating the provided s in a new block of memory allocated as if
@@ -16,8 +16,9 @@ char *strndup(const char *s, size_t size) {
size_t l = strlen(s);
size_t real_l = min(l, size);
char *r = malloc(real_l + 1);
- if (!r)
+ if (!r) {
return NULL;
+ }
strlcpy(r, s, real_l);
return r;
}