The if block can be removed since the realloc can handle NULL pointer
as a first argument.
Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
---
src/perf/perf_bundle.cpp | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/perf/perf_bundle.cpp b/src/perf/perf_bundle.cpp
index 4e70f30..7649036 100644
--- a/src/perf/perf_bundle.cpp
+++ b/src/perf/perf_bundle.cpp
@@ -112,13 +112,10 @@ static char * read_file(const char *file)
exit(-1);
while((r = read(fd, buf, 4096)) > 0) {
- if (len) {
- char *tmp = (char *)realloc(buffer, len + r + 1);
- if (!tmp)
- free(buffer);
- buffer = tmp;
- } else
- buffer = (char *)malloc(r + 1);
+ char *tmp = (char *)realloc(buffer, len + r + 1);
+ if (!tmp)
+ free(buffer);
+ buffer = tmp;
if (!buffer)
goto out;
memcpy(buffer + len, buf, r);
--
1.7.9.2