From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753872AbbFRIOw (ORCPT ); Thu, 18 Jun 2015 04:14:52 -0400 Received: from terminus.zytor.com ([198.137.202.10]:57118 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932101AbbFRIOM (ORCPT ); Thu, 18 Jun 2015 04:14:12 -0400 Date: Thu, 18 Jun 2015 01:13:51 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: eranian@google.com, linux-kernel@vger.kernel.org, ak@linux.intel.com, jolsa@kernel.org, acme@redhat.com, hpa@zytor.com, tglx@linutronix.de, namhyung@kernel.org, mingo@kernel.org, a.p.zijlstra@chello.nl, dsahern@gmail.com, adrian.hunter@intel.com Reply-To: ak@linux.intel.com, eranian@google.com, linux-kernel@vger.kernel.org, adrian.hunter@intel.com, dsahern@gmail.com, a.p.zijlstra@chello.nl, mingo@kernel.org, acme@redhat.com, hpa@zytor.com, namhyung@kernel.org, tglx@linutronix.de, jolsa@kernel.org In-Reply-To: <1434269985-521-2-git-send-email-jolsa@kernel.org> References: <1434269985-521-2-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Introduce xyarray__reset function Git-Commit-ID: b45f65e8fddc89ac6b46388908d3f6ac728be372 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: b45f65e8fddc89ac6b46388908d3f6ac728be372 Gitweb: http://git.kernel.org/tip/b45f65e8fddc89ac6b46388908d3f6ac728be372 Author: Jiri Olsa AuthorDate: Sun, 14 Jun 2015 10:19:16 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 16 Jun 2015 10:34:39 -0300 perf tools: Introduce xyarray__reset function To zero all the xyarray contents. It will be used in following patches. Signed-off-by: Jiri Olsa Cc: Adrian Hunter Cc: Andi Kleen Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1434269985-521-2-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/xyarray.c | 8 ++++++++ tools/perf/util/xyarray.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c index 22afbf6..c10ba41 100644 --- a/tools/perf/util/xyarray.c +++ b/tools/perf/util/xyarray.c @@ -9,11 +9,19 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) if (xy != NULL) { xy->entry_size = entry_size; xy->row_size = row_size; + xy->entries = xlen * ylen; } return xy; } +void xyarray__reset(struct xyarray *xy) +{ + size_t n = xy->entries * xy->entry_size; + + memset(xy->contents, 0, n); +} + void xyarray__delete(struct xyarray *xy) { free(xy); diff --git a/tools/perf/util/xyarray.h b/tools/perf/util/xyarray.h index c488a07..7f30af3 100644 --- a/tools/perf/util/xyarray.h +++ b/tools/perf/util/xyarray.h @@ -6,11 +6,13 @@ struct xyarray { size_t row_size; size_t entry_size; + size_t entries; char contents[]; }; struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size); void xyarray__delete(struct xyarray *xy); +void xyarray__reset(struct xyarray *xy); static inline void *xyarray__entry(struct xyarray *xy, int x, int y) {