diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-04-17 21:51:59 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-04-19 18:01:51 +0200 |
commit | a067558e2fa72445e8f6e6b2dd372a82afae6e49 (patch) | |
tree | 5f8a79cec16d185a0589bf4654cdae2bde91a8b8 /tools/perf/util/string.c | |
parent | perf tools: Move srcline definitions to separate header (diff) | |
download | linux-a067558e2fa72445e8f6e6b2dd372a82afae6e49.tar.xz linux-a067558e2fa72445e8f6e6b2dd372a82afae6e49.zip |
perf tools: Move extra string util functions to util/string2.h
Moving them from util.h, where they don't belong. Since libc already
have string.h, name it slightly differently, as string2.h.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-eh3vz5sqxsrdd8lodoro4jrw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/string.c')
-rw-r--r-- | tools/perf/util/string.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index e716a6e5bb19..cca53b693a48 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c @@ -1,5 +1,7 @@ -#include "util.h" -#include "linux/string.h" +#include "string2.h" +#include <linux/kernel.h> +#include <linux/string.h> +#include <stdlib.h> #include "sane_ctype.h" @@ -101,8 +103,10 @@ static int count_argc(const char *str) void argv_free(char **argv) { char **p; - for (p = argv; *p; p++) - zfree(p); + for (p = argv; *p; p++) { + free(*p); + *p = NULL; + } free(argv); } @@ -122,7 +126,7 @@ void argv_free(char **argv) char **argv_split(const char *str, int *argcp) { int argc = count_argc(str); - char **argv = zalloc(sizeof(*argv) * (argc+1)); + char **argv = calloc(argc + 1, sizeof(*argv)); char **argvp; if (argv == NULL) @@ -379,7 +383,7 @@ char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints goto out_err_overflow; if (i > 0) - printed += snprintf(e + printed, size - printed, " %s ", or_and); + printed += scnprintf(e + printed, size - printed, " %s ", or_and); printed += scnprintf(e + printed, size - printed, "%s %s %d", var, eq_neq, ints[i]); } |