-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Josh Poimboeuf
authored and
Arnaldo Carvalho de Melo
committed
Dec 17, 2015
1 parent
096d355
commit 901421a
Showing
4 changed files
with
66 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#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 */ |