[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-b232e0732b1d763834c3d5b098d25d59337ba075@git.kernel.org>
Date: Thu, 13 Sep 2012 22:59:15 -0700
From: tip-bot for Jiri Olsa <jolsa@...hat.com>
To: linux-tip-commits@...r.kernel.org
Cc: acme@...hat.com, linux-kernel@...r.kernel.org, paulus@...ba.org,
hpa@...or.com, mingo@...nel.org, a.p.zijlstra@...llo.nl,
jolsa@...hat.com, fweisbec@...il.com, tglx@...utronix.de,
mingo@...e.hu
Subject: [tip:perf/core] perf tools: Add memdup function
Commit-ID: b232e0732b1d763834c3d5b098d25d59337ba075
Gitweb: http://git.kernel.org/tip/b232e0732b1d763834c3d5b098d25d59337ba075
Author: Jiri Olsa <jolsa@...hat.com>
AuthorDate: Mon, 10 Sep 2012 18:50:17 +0200
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Tue, 11 Sep 2012 12:04:41 -0300
perf tools: Add memdup function
Adding memdup function to duplicate region of memory.
void *memdup(const void *src, size_t len)
Signed-off-by: Jiri Olsa <jolsa@...hat.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Link: http://lkml.kernel.org/r/1347295819-23177-3-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/include/linux/string.h | 2 ++
tools/perf/util/string.c | 18 +++++++++++++++++-
2 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/tools/perf/util/include/linux/string.h b/tools/perf/util/include/linux/string.h
index 3b2f590..6f19c54 100644
--- a/tools/perf/util/include/linux/string.h
+++ b/tools/perf/util/include/linux/string.h
@@ -1 +1,3 @@
#include <string.h>
+
+void *memdup(const void *src, size_t len);
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
index 199bc4d..3217059 100644
--- a/tools/perf/util/string.c
+++ b/tools/perf/util/string.c
@@ -1,5 +1,5 @@
#include "util.h"
-#include "string.h"
+#include "linux/string.h"
#define K 1024LL
/*
@@ -335,3 +335,19 @@ char *rtrim(char *s)
return s;
}
+
+/**
+ * memdup - duplicate region of memory
+ * @src: memory region to duplicate
+ * @len: memory region length
+ */
+void *memdup(const void *src, size_t len)
+{
+ void *p;
+
+ p = malloc(len);
+ if (p)
+ memcpy(p, src, len);
+
+ return p;
+}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists