lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Thu, 20 Dec 2012 17:05:50 +0800
From:	chenggang <chenggang.qin@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	chenggang <chenggang.qin@...il.com>,
	David Ahern <dsahern@...il.com>,
	Arjan van de Ven <arjan@...ux.intel.com>,
	Namhyung Kim <namhyung@...il.com>,
	Yanmin Zhang <yanmin.zhang@...el.com>,
	Wu Fengguang <fengguang.wu@...el.com>,
	Mike Galbraith <efault@....de>,
	Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Chenggang Qin <chenggang.qcg@...bao.com>
Subject: [PATCH 2/5] perf tools: Add xyarray__realloc function in xyarray.c to expend xyarray.

xyarray__realloc() could be used if we wish extend the evsel->fd,
evsel->sample_id or any other xyarray on-the-fly.

Cc: David Ahern <dsahern@...il.com>
Cc: Arjan van de Ven <arjan@...ux.intel.com>
Cc: Namhyung Kim <namhyung@...il.com>
Cc: Yanmin Zhang <yanmin.zhang@...el.com>
Cc: Wu Fengguang <fengguang.wu@...el.com>
Cc: Mike Galbraith <efault@....de>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Chenggang Qin <chenggang.qcg@...bao.com>
---
 tools/perf/util/xyarray.c |   26 ++++++++++++++++++++++++++
 tools/perf/util/xyarray.h |    2 ++
 2 files changed, 28 insertions(+)

diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c
index 22afbf6..4e76377 100644
--- a/tools/perf/util/xyarray.c
+++ b/tools/perf/util/xyarray.c
@@ -18,3 +18,29 @@ void xyarray__delete(struct xyarray *xy)
 {
 	free(xy);
 }
+
+int xyarray__realloc(struct xyarray **xy_old, int xlen_old, int xlen_new,
+		      int ylen_new)
+{
+	size_t row_size_new = ylen_new * (*xy_old)->entry_size;
+	struct xyarray *xy_new = zalloc(sizeof(*xy_new) + xlen_new
+					* row_size_new);
+	int x;
+
+	if (xy_new != NULL) {
+		for (x = 0; x < xlen_old; x++)
+			memcpy(&xy_new->contents[x * row_size_new],
+			       &((*xy_old)->contents[x * (*xy_old)->row_size]),
+			       (*xy_old)->row_size);
+
+		xy_new->row_size = row_size_new;
+		xy_new->entry_size = (*xy_old)->entry_size;
+
+		xyarray__delete(*xy_old);
+
+		*xy_old = xy_new;
+
+		return 0;
+	}
+
+	return -1;
+}
+
diff --git a/tools/perf/util/xyarray.h b/tools/perf/util/xyarray.h
index c488a07..ad41649 100644
--- a/tools/perf/util/xyarray.h
+++ b/tools/perf/util/xyarray.h
@@ -11,6 +11,8 @@ struct xyarray {
 
 struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
 void xyarray__delete(struct xyarray *xy);
+int xyarray__realloc(struct xyarray **xy_old, int xlen_old, int xlen_new,
+		     int ylen_new);
 
 static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
 {
-- 
1.7.9.5

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ