#include "stdio_impl.h"
+#include <errno.h>
+#include <string.h>
+#include <inttypes.h>
struct cookie {
size_t pos, len, size;
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;
return 0;
}
- if (!buf && size > SIZE_MAX-sizeof(FILE)-BUFSIZ-UNGET) {
+ if (!buf && size > PTRDIFF_MAX) {
errno = ENOMEM;
return 0;
}
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;
- return f;
+ return __ofl_add(f);
}