mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 15:56:18 +02:00
Apply suggestions from code review
This commit is contained in:
parent
550af113c6
commit
46f5d0ee7b
1 changed files with 8 additions and 1 deletions
|
@ -183,7 +183,14 @@ const char * nix_get_path_string(nix_c_context * context, const Value * value)
|
||||||
try {
|
try {
|
||||||
auto & v = check_value_not_null(value);
|
auto & v = check_value_not_null(value);
|
||||||
assert(v.type() == nix::nPath);
|
assert(v.type() == nix::nPath);
|
||||||
return v.path().to_string().c_str();
|
// NOTE (from @yorickvP)
|
||||||
|
// v._path.path should work but may not be how Eelco intended it.
|
||||||
|
// Long-term this function should be rewritten to copy some data into a
|
||||||
|
// user-allocated string.
|
||||||
|
// We could use v.path().to_string().c_str(), but I'm concerned this
|
||||||
|
// crashes. Looks like .path() allocates a CanonPath with a copy of the
|
||||||
|
// string, then it gets the underlying data from that.
|
||||||
|
return v._path.path;
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS_NULL
|
NIXC_CATCH_ERRS_NULL
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue