1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00

Use less c_str() in the evaluator, and other cleanups

It is better to avoid null termination for performance and memory
safety, wherever possible.

These are good cleanups extracted from the Pascal String work that we
can land by themselves first, shrinking the diff in that PR.

Co-Authored-By: Aspen Smith <root@gws.fyi>
Co-Authored-By: Sergei Zimmerman <sergei@zimmerman.foo>
This commit is contained in:
John Ericson 2025-11-01 16:54:22 -04:00 committed by Sergei Zimmerman
parent 2d83bc6b83
commit bd42092873
No known key found for this signature in database
16 changed files with 64 additions and 38 deletions

View file

@ -153,9 +153,9 @@ nix_err nix_err_code(const nix_c_context * read_context)
}
// internal
nix_err call_nix_get_string_callback(const std::string str, nix_get_string_callback callback, void * user_data)
nix_err call_nix_get_string_callback(const std::string_view str, nix_get_string_callback callback, void * user_data)
{
callback(str.c_str(), str.size(), user_data);
callback(str.data(), str.size(), user_data);
return NIX_OK;
}