From b5cd18739a64c8d923a55b61c89ae3900faafd84 Mon Sep 17 00:00:00 2001 From: Kacper Date: Tue, 9 Dec 2025 21:17:12 +0100 Subject: Fix include paths and formatting inconsistencies --- lib/libc/stdio/fmemopen.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'lib/libc/stdio/fmemopen.c') diff --git a/lib/libc/stdio/fmemopen.c b/lib/libc/stdio/fmemopen.c index b1fa0f8a..21e811fd 100644 --- a/lib/libc/stdio/fmemopen.c +++ b/lib/libc/stdio/fmemopen.c @@ -1,10 +1,13 @@ -#include -#include -#include -#include -#include -#include -#include +#include "__stdio.h" // for __libc_fadd +#include "features.h" // for __weak +#include "stddef.h" // for NULL + +#include // for EINVAL, errno +#include // for O_WRONLY, O_CREAT, O_RDONLY, O_APPEND, O_RDWR +#include // for __IMPL +#include // for FILE, _IOFBF, fmemopen, size_t +#include // for calloc, free +#include // for strchr __weak void __stdio_cleanup(void) { @@ -13,15 +16,15 @@ __weak void __stdio_cleanup(void) FILE *fmemopen(void *restrict buf, size_t max_size, const char *restrict mode) { int flags; - FILE *f = calloc(1, sizeof(FILE)); + FILE *stream = calloc(1, sizeof(FILE)); - if (f == NULL) - return f; + if (stream == NULL) + return stream; - f->fd = -1; - f->buf = buf; - f->buf_size = max_size; - f->type = _IOFBF; + __IMPL(stream)->fd = -1; + __IMPL(stream)->buf = buf; + __IMPL(stream)->buf_size = max_size; + __IMPL(stream)->type = _IOFBF; if (mode[0] == 'r') { flags = O_RDONLY; @@ -30,7 +33,7 @@ FILE *fmemopen(void *restrict buf, size_t max_size, const char *restrict mode) } else if (mode[0] == 'a') { flags = O_WRONLY | O_CREAT | O_APPEND; } else { - free(f); + free(stream); errno = EINVAL; return NULL; } @@ -39,9 +42,9 @@ FILE *fmemopen(void *restrict buf, size_t max_size, const char *restrict mode) flags = (flags & ~(O_RDONLY | O_WRONLY)) | O_RDWR; } - f->flags = flags; + __IMPL(stream)->flags = flags; - __libc_fadd(f); + __libc_fadd(stream); - return f; + return stream; } -- cgit v1.2.3