1
0
Fork 0

Adding upstream version 2.14.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-22 13:00:33 +02:00
parent 94a061187a
commit dbdc28cb89
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
572 changed files with 4636 additions and 1730 deletions

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <stdio.h>
#include <errno.h>
#include <stdarg.h>
#include "json.h"
#include "types.h"
@ -135,3 +136,18 @@ void json_object_add_0nprix64(struct json_object *o, const char *k, uint64_t v,
sprintf(str, "0x%0*"PRIx64"", width, v);
json_object_add_value_string(o, k, str);
}
void json_object_add_string(struct json_object *o, const char *k, const char *format, ...)
{
_cleanup_free_ char *value = NULL;
va_list ap;
va_start(ap, format);
if (vasprintf(&value, format, ap) < 0)
value = NULL;
json_object_add_value_string(o, k, value ? value : "Could not allocate string");
va_end(ap);
}