Add open_memstream_unlocked() wrapper
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdio_ext.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
@@ -330,12 +329,10 @@ int calendar_spec_to_string(const CalendarSpec *c, char **p) {
|
||||
assert(c);
|
||||
assert(p);
|
||||
|
||||
f = open_memstream(&buf, &sz);
|
||||
f = open_memstream_unlocked(&buf, &sz);
|
||||
if (!f)
|
||||
return -ENOMEM;
|
||||
|
||||
(void) __fsetlocking(f, FSETLOCKING_BYCALLER);
|
||||
|
||||
if (c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS) {
|
||||
format_weekdays(f, c);
|
||||
fputc(' ', f);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio_ext.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "fd-util.h"
|
||||
@@ -1376,12 +1375,10 @@ int table_format(Table *t, char **ret) {
|
||||
size_t sz = 0;
|
||||
int r;
|
||||
|
||||
f = open_memstream(&buf, &sz);
|
||||
f = open_memstream_unlocked(&buf, &sz);
|
||||
if (!f)
|
||||
return -ENOMEM;
|
||||
|
||||
(void) __fsetlocking(f, FSETLOCKING_BYCALLER);
|
||||
|
||||
r = table_print(t, f);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
+1
-4
@@ -4,7 +4,6 @@
|
||||
#include <locale.h>
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio_ext.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
@@ -1558,12 +1557,10 @@ int json_variant_format(JsonVariant *v, JsonFormatFlags flags, char **ret) {
|
||||
{
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
|
||||
f = open_memstream(&s, &sz);
|
||||
f = open_memstream_unlocked(&s, &sz);
|
||||
if (!f)
|
||||
return -ENOMEM;
|
||||
|
||||
(void) __fsetlocking(f, FSETLOCKING_BYCALLER);
|
||||
|
||||
json_variant_dump(v, flags, f, NULL);
|
||||
|
||||
r = fflush_and_check(f);
|
||||
|
||||
Reference in New Issue
Block a user