summaryrefslogtreecommitdiff
path: root/sys-utils/prlimit.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys-utils/prlimit.c')
-rw-r--r--sys-utils/prlimit.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c
index 9098e4976..5bb99d1ec 100644
--- a/sys-utils/prlimit.c
+++ b/sys-utils/prlimit.c
@@ -144,8 +144,6 @@ static int prlimit(pid_t p, int resource,
}
#endif
-static void rem_prlim(struct prlimit *lim);
-
static void __attribute__ ((__noreturn__)) usage(FILE * out)
{
size_t i;
@@ -228,20 +226,20 @@ static void add_tt_line(struct tt *tt, struct prlimit *l)
switch (get_column_id(i)) {
case COL_RES:
- xasprintf(&str, "%s", l->desc->name);
+ str = xstrdup(l->desc->name);
break;
case COL_HELP:
- xasprintf(&str, "%s", l->desc->help);
+ str = xstrdup(l->desc->help);
break;
case COL_SOFT:
if (l->rlim.rlim_cur == RLIM_INFINITY)
- xasprintf(&str, "%s", "unlimited");
+ str = xstrdup(_("unlimited"));
else
xasprintf(&str, "%llu", (unsigned long long) l->rlim.rlim_cur);
break;
case COL_HARD:
if (l->rlim.rlim_max == RLIM_INFINITY)
- xasprintf(&str, "%s", "unlimited");
+ str = xstrdup(_("unlimited"));
else
xasprintf(&str, "%llu", (unsigned long long) l->rlim.rlim_max);
break;
@@ -273,13 +271,21 @@ static int column_name_to_id(const char *name, size_t namesz)
return -1;
}
+static void rem_prlim(struct prlimit *lim)
+{
+ if (!lim)
+ return;
+ list_del(&lim->lims);
+ free(lim);
+}
+
static int show_limits(struct list_head *lims, int tt_flags)
{
int i;
struct list_head *p, *pnext;
struct tt *tt;
- tt = tt_new_table(tt_flags);
+ tt = tt_new_table(tt_flags | TT_FL_FREEDATA);
if (!tt) {
warn(_("failed to initialize output table"));
return -1;
@@ -372,8 +378,6 @@ static void do_prlimit(struct list_head *lims)
}
}
-
-
static int get_range(char *str, rlim_t *soft, rlim_t *hard, int *found)
{
char *end = NULL;
@@ -466,14 +470,6 @@ static int add_prlim(char *ops, struct list_head *lims, size_t id)
return 0;
}
-static void rem_prlim(struct prlimit *lim)
-{
- if (!lim)
- return;
- list_del(&lim->lims);
- free(lim);
-}
-
int main(int argc, char **argv)
{
int opt, tt_flags = 0;