X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Fopen_memstream.c;h=9eafdfbaedce42c1bc86165719638e5e335f822e;hb=be81f51030d90de8d5eb0b65dbdab3032d5cae23;hp=687e818dbd5cc857acb98e30d126889f297478c0;hpb=7ee3dcb3c603b20fcd4547ffb00e11701c6d1cf4;p=musl diff --git a/src/stdio/open_memstream.c b/src/stdio/open_memstream.c index 687e818d..9eafdfba 100644 --- a/src/stdio/open_memstream.c +++ b/src/stdio/open_memstream.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include struct cookie { char **bufp; @@ -74,12 +77,13 @@ FILE *open_memstream(char **bufp, size_t *sizep) f->seek = ms_seek; f->close = ms_close; - 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; }