mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 06:26:15 +02:00
Remove all the occurences of VLAs
There's generally no strict reason for using them, and they are somewhat fishy, so let's avoid them.
This commit is contained in:
parent
5196613e82
commit
ba3cb4a049
3 changed files with 14 additions and 17 deletions
|
@ -41,6 +41,7 @@
|
||||||
#include <boost/coroutine2/coroutine.hpp>
|
#include <boost/coroutine2/coroutine.hpp>
|
||||||
#include <boost/coroutine2/protected_fixedsize_stack.hpp>
|
#include <boost/coroutine2/protected_fixedsize_stack.hpp>
|
||||||
#include <boost/context/stack_context.hpp>
|
#include <boost/context/stack_context.hpp>
|
||||||
|
#include <boost/container/small_vector.hpp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1691,7 +1692,8 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
|
||||||
/* We have all the arguments, so call the primop with
|
/* We have all the arguments, so call the primop with
|
||||||
the previous and new arguments. */
|
the previous and new arguments. */
|
||||||
|
|
||||||
Value * vArgs[arity];
|
assert(arity < 64);
|
||||||
|
Value * vArgs[64];
|
||||||
auto n = argsDone;
|
auto n = argsDone;
|
||||||
for (Value * arg = &vCur; arg->isPrimOpApp(); arg = arg->primOpApp.left)
|
for (Value * arg = &vCur; arg->isPrimOpApp(); arg = arg->primOpApp.left)
|
||||||
vArgs[--n] = arg->primOpApp.right;
|
vArgs[--n] = arg->primOpApp.right;
|
||||||
|
@ -1748,11 +1750,12 @@ void ExprCall::eval(EvalState & state, Env & env, Value & v)
|
||||||
Value vFun;
|
Value vFun;
|
||||||
fun->eval(state, env, vFun);
|
fun->eval(state, env, vFun);
|
||||||
|
|
||||||
Value * vArgs[args.size()];
|
|
||||||
|
boost::container::small_vector<Value *, 64> vArgs(args.size());
|
||||||
for (size_t i = 0; i < args.size(); ++i)
|
for (size_t i = 0; i < args.size(); ++i)
|
||||||
vArgs[i] = args[i]->maybeThunk(state, env);
|
vArgs[i] = args[i]->maybeThunk(state, env);
|
||||||
|
|
||||||
state.callFunction(vFun, args.size(), vArgs, v, pos);
|
state.callFunction(vFun, args.size(), vArgs.data(), v, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1991,8 +1994,8 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
Value values[es->size()];
|
boost::container::small_vector<Value, 64> values(es->size());
|
||||||
Value * vTmpP = values;
|
Value * vTmpP = values.data();
|
||||||
|
|
||||||
for (auto & [i_pos, i] : *es) {
|
for (auto & [i_pos, i] : *es) {
|
||||||
Value & vTmp = *vTmpP++;
|
Value & vTmp = *vTmpP++;
|
||||||
|
|
|
@ -151,11 +151,10 @@ StorePath writeDerivation(Store & store,
|
||||||
/* Read string `s' from stream `str'. */
|
/* Read string `s' from stream `str'. */
|
||||||
static void expect(std::istream & str, std::string_view s)
|
static void expect(std::istream & str, std::string_view s)
|
||||||
{
|
{
|
||||||
char s2[s.size()];
|
for (auto & c : s) {
|
||||||
str.read(s2, s.size());
|
if (str.get() != c)
|
||||||
std::string_view s2View { s2, s.size() };
|
throw FormatError("expected string '%1%'", s);
|
||||||
if (s2View != s)
|
}
|
||||||
throw FormatError("expected string '%s', got '%s'", s, s2View);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -330,9 +330,7 @@ typedef std::unordered_map<Path, std::unordered_set<std::string>> UncheckedRoots
|
||||||
|
|
||||||
static void readProcLink(const std::string & file, UncheckedRoots & roots)
|
static void readProcLink(const std::string & file, UncheckedRoots & roots)
|
||||||
{
|
{
|
||||||
/* 64 is the starting buffer size gnu readlink uses... */
|
constexpr auto bufsiz = PATH_MAX;
|
||||||
auto bufsiz = ssize_t{64};
|
|
||||||
try_again:
|
|
||||||
char buf[bufsiz];
|
char buf[bufsiz];
|
||||||
auto res = readlink(file.c_str(), buf, bufsiz);
|
auto res = readlink(file.c_str(), buf, bufsiz);
|
||||||
if (res == -1) {
|
if (res == -1) {
|
||||||
|
@ -341,10 +339,7 @@ try_again:
|
||||||
throw SysError("reading symlink");
|
throw SysError("reading symlink");
|
||||||
}
|
}
|
||||||
if (res == bufsiz) {
|
if (res == bufsiz) {
|
||||||
if (SSIZE_MAX / 2 < bufsiz)
|
|
||||||
throw Error("stupidly long symlink");
|
throw Error("stupidly long symlink");
|
||||||
bufsiz *= 2;
|
|
||||||
goto try_again;
|
|
||||||
}
|
}
|
||||||
if (res > 0 && buf[0] == '/')
|
if (res > 0 && buf[0] == '/')
|
||||||
roots[std::string(static_cast<char *>(buf), res)]
|
roots[std::string(static_cast<char *>(buf), res)]
|
||||||
|
|
Loading…
Reference in a new issue