Skip to content

Commit

Permalink
spawn/ResourceLimits: use std::array
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Dec 11, 2023
1 parent e4f6424 commit 4d9ee30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/spawn/ResourceLimits.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ rlimit_apply(int pid, int resource, const ResourceLimit &r)
void
ResourceLimits::Apply(int pid) const
{
for (unsigned i = 0; i < RLIM_NLIMITS; ++i)
for (unsigned i = 0; i < values.size(); ++i)
rlimit_apply(pid, i, values[i]);
}

Expand Down Expand Up @@ -222,7 +222,7 @@ ResourceLimits::Parse(const char *s) noexcept
return false;
}

assert(resource < RLIM_NLIMITS);
assert(resource < values.size());
struct rlimit *const t = &values[resource];

unsigned long value;
Expand Down
3 changes: 2 additions & 1 deletion src/spawn/ResourceLimits.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <sys/resource.h>

#include <array>
#include <cstddef>

struct ResourceLimit : rlimit {
Expand Down Expand Up @@ -44,7 +45,7 @@ struct ResourceLimit : rlimit {
* Resource limits.
*/
struct ResourceLimits {
ResourceLimit values[RLIM_NLIMITS];
std::array<ResourceLimit, RLIM_NLIMITS> values;

[[gnu::pure]]
bool IsEmpty() const noexcept;
Expand Down

0 comments on commit 4d9ee30

Please sign in to comment.