linux-pinenote/tools/perf/util/subcmd-util.h
Josh Poimboeuf 901421a5bd perf tools: Remove subcmd dependencies on strbuf
Introduce and use new astrcat() and astrcatf() functions which replace
the strbuf functionality for subcmd.

For now they duplicate strbuf's die-on-allocation-error policy.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/957d207e1254406fa11fc2e405e75a7e405aad8f.1450193761.git.jpoimboe@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-16 21:33:13 -03:00

24 lines
486 B
C

#ifndef __PERF_SUBCMD_UTIL_H
#define __PERF_SUBCMD_UTIL_H
#include <stdio.h>
#define astrcatf(out, fmt, ...) \
({ \
char *tmp = *(out); \
if (asprintf((out), "%s" fmt, tmp ?: "", ## __VA_ARGS__) == -1) \
die("asprintf failed"); \
free(tmp); \
})
static inline void astrcat(char **out, const char *add)
{
char *tmp = *out;
if (asprintf(out, "%s%s", tmp ?: "", add) == -1)
die("asprintf failed");
free(tmp);
}
#endif /* __PERF_SUBCMD_UTIL_H */