When the appended data points into the printbuf itself, growing the buffer may invalidate the source pointer before it is copied. Preserve the source offset across realloc and use memmove for internal overlap.
The -lm was missing in the pkgconfig file that was generated. This adds that similar to the CMake build system's output.
Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>
Signed-off-by: Sam James <sam@gentoo.org>
Fix includedir and libdir to have proper paths (not just relative ones
to prefix).
Using Meson's native pkgconfig module is the best way of doing this.
Signed-off-by: Sam James <sam@gentoo.org>
Tests will now be built at `meson test`-time, so there's no cost if the
user isn't going to run them.
This is better than guarding on build type, as distros may want to test production
builds before shipping.
Signed-off-by: Sam James <sam@gentoo.org>
This is more elegant as a meson feature option because feature options
propagate in a useful way to `dependency(..., required: ...)`.
Without this, the option was ignored. Wiring it up naively meant that
disabling it still searched for libbsd as well, so a feature option
is the best fit.
Also, mark it as a dependency of `arc4random`.
Signed-off-by: Sam James <sam@gentoo.org>
The iterative rewrite in 17328a67 made json_object_put() return 0 for freed scalars, strings and empty containers, contradicting the documented contract in json_object.h. Distinguish "freed" from "still referenced" in _json_object_put_maybe_free() and add regression tests.
This commit fixes the install path for json-c headers when running `meson install`.
Previously some showed in /usr/include/ rather than /usr/include/json-c
This also adds generating the pkgconfig .pc file for this project.
Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>
The meson workflow only builds and tests across platforms; none of its
jobs write to the repository, packages, or other GitHub resources. Add a
workflow-level `permissions: { contents: read }` block so the default
GITHUB_TOKEN follows least privilege instead of inheriting the broad
read/write scopes granted by default.
This patch fixes the build error with clang-21
tests/test_deep_nesting.c:19:34: error: a function declaration
without a prototype is deprecated in all versions of C
[-Werror,-Wstrict-prototypes]
19 | static char *generate_json_string()
by fixing generate_json_string() definition.
It also removes prototypes for static functions that are not needed.