rlimit-util: add a common destructor call for arrays of struct rlimit

This commit is contained in:
Lennart Poettering
2018-05-17 20:36:52 +02:00
parent 4f424df760
commit 31ce987c2b
4 changed files with 15 additions and 5 deletions
+10
View File
@@ -324,3 +324,13 @@ int rlimit_from_string_harder(const char *s) {
return rlimit_from_string(s);
}
void rlimit_free_all(struct rlimit **rl) {
int i;
if (!rl)
return;
for (i = 0; i < _RLIMIT_MAX; i++)
rl[i] = mfree(rl[i]);
}
+2
View File
@@ -22,4 +22,6 @@ int rlimit_parse(int resource, const char *val, struct rlimit *ret);
int rlimit_format(const struct rlimit *rl, char **ret);
void rlimit_free_all(struct rlimit **rl);
#define RLIMIT_MAKE_CONST(lim) ((struct rlimit) { lim, lim })