Compare commits

..

No commits in common. "2abb43d70964cc09f822960c21ca07a597bb1a88" and "30ff704342ea9f82c8d4e088ca7473a2b6b5dce3" have entirely different histories.

5 changed files with 2 additions and 16 deletions

View File

@ -49,7 +49,6 @@ Result<u64> ScriptLoader::load(AddressSpace* space)
Result<Vector<String>> ScriptLoader::cmdline(const String& path, Vector<String> args)
{
Vector<String> new_args;
TRY(new_args.try_reserve(m_interpreter_cmdline.size() + args.size() + 1));
for (auto& arg : m_interpreter_cmdline) { TRY(new_args.try_append(move(arg))); }
auto arg = TRY(path.clone());
TRY(new_args.try_append(move(arg)));

View File

@ -17,12 +17,10 @@ Result<u64> sys_poll(Registers*, SyscallArgs args)
if (!MemoryManager::copy_from_user(fds, kfds, nfds * sizeof(pollfd))) return err(EFAULT);
Vector<SharedPtr<VFS::Inode>> inodes;
auto* current = Scheduler::current();
TRY(check_pledge(current, Promise::p_stdio));
Vector<SharedPtr<VFS::Inode>> inodes;
TRY(inodes.try_reserve(nfds));
for (nfds_t i = 0; i < nfds; i++)
{
int fd = kfds[i].fd;

View File

@ -88,7 +88,6 @@ Result<u64> ThreadImage::push_mem_on_stack(const u8* mem, usize size)
Result<u64> ThreadImage::push_string_vector_on_stack(const Vector<String>& vec)
{
Vector<u64> user_vec;
TRY(user_vec.try_reserve(vec.size() + 1));
for (const auto& item : vec)
{
// Copy each individual string and retrieve a userspace pointer to said copy

View File

@ -62,7 +62,7 @@ template <typename T> class Vector
Result<void> try_append(T&& item)
{
if (m_capacity == m_size) TRY(resize(m_capacity ? m_capacity * 2 : 8));
if (m_capacity == m_size) TRY(resize(m_capacity + 8));
new (&m_data[m_size]) T(move(item));
@ -252,8 +252,6 @@ template <typename T> class Vector
Result<void> resize(usize new_capacity)
{
if (new_capacity < m_capacity) return {};
const usize new_byte_capacity = new_capacity * sizeof(T);
void* const ptr = TRY(realloc_impl(m_data, new_byte_capacity));

View File

@ -26,7 +26,6 @@ namespace os
Result<void> Process::exec(StringView path, Slice<String> args, bool search_in_path)
{
Vector<const char*> argv;
TRY(argv.try_reserve(args.size() + 1));
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
TRY(argv.try_append(nullptr));
@ -40,7 +39,6 @@ namespace os
Result<void> Process::exec(StringView path, Slice<StringView> args, bool search_in_path)
{
Vector<const char*> argv;
TRY(argv.try_reserve(args.size() + 1));
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
TRY(argv.try_append(nullptr));
@ -54,12 +52,10 @@ namespace os
Result<void> Process::exec(StringView path, Slice<String> args, Slice<String> env, bool search_in_path)
{
Vector<const char*> argv;
TRY(argv.try_reserve(args.size() + 1));
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
TRY(argv.try_append(nullptr));
Vector<const char*> envp;
TRY(envp.try_reserve(env.size() + 1));
for (const auto& arg : env) { TRY(envp.try_append(arg.chars())); }
TRY(envp.try_append(nullptr));
@ -87,7 +83,6 @@ namespace os
Result<pid_t> Process::spawn(StringView path, Slice<String> args, bool search_in_path)
{
Vector<const char*> argv;
TRY(argv.try_reserve(args.size() + 1));
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
TRY(argv.try_append(nullptr));
@ -97,7 +92,6 @@ namespace os
Result<pid_t> Process::spawn(StringView path, Slice<StringView> args, bool search_in_path)
{
Vector<const char*> argv;
TRY(argv.try_reserve(args.size() + 1));
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
TRY(argv.try_append(nullptr));
@ -107,12 +101,10 @@ namespace os
Result<pid_t> Process::spawn(StringView path, Slice<String> args, Slice<String> env, bool search_in_path)
{
Vector<const char*> argv;
TRY(argv.try_reserve(args.size() + 1));
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
TRY(argv.try_append(nullptr));
Vector<const char*> envp;
TRY(envp.try_reserve(env.size() + 1));
for (const auto& arg : env) { TRY(envp.try_append(arg.chars())); }
TRY(envp.try_append(nullptr));