refactor(3p/nix/libexpr): Store nix::Env values in a std::vector
This has several advantages: * we can ensure that the vector is traced by the GC * we don't need to unsafely allocate memory to make an Env Note that there was previously a check about the size of the environment, but it's unclear why this was the case (git history yielded nothing interesting) and it seems to have no effect. Change-Id: I4998b879a728a6fb68e1bd187c521e2304e5047e Reviewed-on: https://cl.tvl.fyi/c/depot/+/1265 Tested-by: BuildkiteCI Reviewed-by: isomer <isomer@tvl.fyi> Reviewed-by: Kane York <rikingcoding@gmail.com> Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
parent
effbb277c3
commit
56614c75e4
2 changed files with 11 additions and 9 deletions
8
third_party/nix/src/libexpr/eval.cc
vendored
8
third_party/nix/src/libexpr/eval.cc
vendored
|
|
@ -338,8 +338,6 @@ EvalState::EvalState(const Strings& _searchPath, const ref<Store>& store)
|
|||
|
||||
assert(gcInitialised);
|
||||
|
||||
static_assert(sizeof(Env) <= 16, "environment must be <= 16 bytes");
|
||||
|
||||
/* Initialise the Nix expression search path. */
|
||||
if (!evalSettings.pureEval) {
|
||||
Strings paths = parseNixPath(getEnv("NIX_PATH", ""));
|
||||
|
|
@ -637,13 +635,9 @@ Env& EvalState::allocEnv(size_t size) {
|
|||
|
||||
nrEnvs++;
|
||||
nrValuesInEnvs += size;
|
||||
Env* env = (Env*)allocBytes(sizeof(Env) + size * sizeof(Value*));
|
||||
env->size = (decltype(Env::size))size;
|
||||
Env* env = new Env(size);
|
||||
env->type = Env::Plain;
|
||||
|
||||
/* We assume that env->values has been cleared by the allocator; maybeThunk()
|
||||
* and lookupVar fromWith expect this. */
|
||||
|
||||
return *env;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue