Fix JSON handling copy vs. ref semantics by zwass · Pull Request #8738 · osquery/osquery

@zwass

- Remove duplication in functions (add/addCopy were basically the same)
- Fix addRef to actually reference the value (previously it was also copying)
- Use addRef in some places (such as file carving) where it can save on allocations

Verified by running allocations profile with Instruments on macOS and
observing that with the changes addRef creates fewer allocations.

There may be other places where addRef can be used, and there may be
places where a pushRef could make sense. This PR aims to make the
names at least consistent with the behaviors.

@zwass zwass marked this pull request as ready for review

January 8, 2026 02:02

sharvilshah

zwass added a commit to zwass/osquery that referenced this pull request

Feb 18, 2026

@zwass zwass mentioned this pull request

Feb 18, 2026

zwass added a commit that referenced this pull request

Feb 19, 2026
Modified code in #8740 used the JSON function that was refactored in
#8738. This breaks the build.