Add fmemopen_unlocked() and use unlocked ops in fuzzers and some other tests
This might make things marginially faster. I didn't benchmark though.
This commit is contained in:
@@ -65,6 +65,16 @@ FILE* open_memstream_unlocked(char **ptr, size_t *sizeloc) {
|
||||
return f;
|
||||
}
|
||||
|
||||
FILE* fmemopen_unlocked(void *buf, size_t size, const char *mode) {
|
||||
FILE *f = fmemopen(buf, size, mode);
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
(void) __fsetlocking(f, FSETLOCKING_BYCALLER);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
int write_string_stream_ts(
|
||||
FILE *f,
|
||||
const char *line,
|
||||
|
||||
@@ -36,6 +36,7 @@ typedef enum {
|
||||
int fopen_unlocked(const char *path, const char *options, FILE **ret);
|
||||
int fdopen_unlocked(int fd, const char *options, FILE **ret);
|
||||
FILE* open_memstream_unlocked(char **ptr, size_t *sizeloc);
|
||||
FILE* fmemopen_unlocked(void *buf, size_t size, const char *mode);
|
||||
|
||||
int write_string_stream_ts(FILE *f, const char *line, WriteStringFileFlags flags, struct timespec *ts);
|
||||
static inline int write_string_stream(FILE *f, const char *line, WriteStringFileFlags flags) {
|
||||
|
||||
Reference in New Issue
Block a user