summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/open_memstream.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/stdio/open_memstream.c
parentdcbcdbdc5bcfb86eca05fb655e3bf009d89e39e0 (diff)
formatting: Use clang-format on all projects
This commit also add braces to all `if` statements.
Diffstat (limited to 'userland/libc/stdio/open_memstream.c')
-rw-r--r--userland/libc/stdio/open_memstream.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/userland/libc/stdio/open_memstream.c b/userland/libc/stdio/open_memstream.c
index b129cb6..b7ea70b 100644
--- a/userland/libc/stdio/open_memstream.c
+++ b/userland/libc/stdio/open_memstream.c
@@ -35,8 +35,9 @@ size_t memstream_write(FILE *fp, const unsigned char *buf, size_t n) {
memcpy(c->buffer + fp->offset_in_file, buf, n);
fp->offset_in_file += n;
- if (fp->offset_in_file > (long)c->buffer_usage)
+ if (fp->offset_in_file > (long)c->buffer_usage) {
c->buffer_usage = fp->offset_in_file;
+ }
return n;
}
@@ -46,8 +47,9 @@ size_t memstream_read(FILE *fp, unsigned char *buf, size_t n) {
n = min(length_left, n);
memcpy(buf, c->buffer + fp->offset_in_file, n);
fp->offset_in_file += n;
- if (0 == n)
+ if (0 == n) {
fp->is_eof = 1;
+ }
return n;
}
@@ -73,8 +75,9 @@ int memstream_seek(FILE *stream, long offset, int whence) {
FILE *open_memstream(char **bufp, size_t *sizep) {
struct Memstream *c = NULL;
FILE *fp = malloc(sizeof(FILE));
- if (!fp)
+ if (!fp) {
return NULL;
+ }
fp->offset_in_file = 0;
fp->buffered_char = 0;