X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fstdio%2Ffmemopen.c;h=d78496091d255a9d54d57ca0f075ce1c84e8487f;hp=1b054a970445e71ba5e86d363833c05fceb6faf3;hb=41d7c77d6a2e74294807d35062e4cd1d48ab72d3;hpb=d2e061a2bd3f7674cfef2e2217e0695419041b5e diff --git a/src/stdio/fmemopen.c b/src/stdio/fmemopen.c index 1b054a97..d7849609 100644 --- a/src/stdio/fmemopen.c +++ b/src/stdio/fmemopen.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include struct cookie { size_t pos, len, size; @@ -67,7 +70,7 @@ static int mclose(FILE *m) return 0; } -FILE *fmemopen(void *buf, size_t size, const char *mode) +FILE *fmemopen(void *restrict buf, size_t size, const char *restrict mode) { FILE *f; struct cookie *c; @@ -105,12 +108,13 @@ FILE *fmemopen(void *buf, size_t size, const char *mode) f->seek = mseek; f->close = mclose; - if (!libc.threaded) { - f->lock = -1; - f->next = libc.ofl_head; - if (libc.ofl_head) libc.ofl_head->prev = f; - libc.ofl_head = f; - } + if (!libc.threaded) f->lock = -1; + + OFLLOCK(); + f->next = libc.ofl_head; + if (libc.ofl_head) libc.ofl_head->prev = f; + libc.ofl_head = f; + OFLUNLOCK(); return f; }