From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752676AbdLFQlV (ORCPT ); Wed, 6 Dec 2017 11:41:21 -0500 Received: from terminus.zytor.com ([65.50.211.136]:38951 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752228AbdLFQlR (ORCPT ); Wed, 6 Dec 2017 11:41:17 -0500 Date: Wed, 6 Dec 2017 08:36:56 -0800 From: tip-bot for Jin Yao Message-ID: Cc: hpa@zytor.com, yao.jin@linux.intel.com, ak@linux.intel.com, acme@redhat.com, tglx@linutronix.de, mingo@kernel.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, kan.liang@intel.com, alexander.shishkin@linux.intel.com, peterz@infradead.org Reply-To: alexander.shishkin@linux.intel.com, peterz@infradead.org, kan.liang@intel.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, acme@redhat.com, hpa@zytor.com, yao.jin@linux.intel.com, ak@linux.intel.com In-Reply-To: <1512125856-22056-2-git-send-email-yao.jin@linux.intel.com> References: <1512125856-22056-2-git-send-email-yao.jin@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf rblist: Create rblist__exit() function Git-Commit-ID: 33fec3e393dc1c55737cfb9c876b5c0da0d6f380 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: 33fec3e393dc1c55737cfb9c876b5c0da0d6f380 Gitweb: https://git.kernel.org/tip/33fec3e393dc1c55737cfb9c876b5c0da0d6f380 Author: Jin Yao AuthorDate: Fri, 1 Dec 2017 18:57:25 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 5 Dec 2017 10:24:31 -0300 perf rblist: Create rblist__exit() function Currently we have a rblist__delete() which is used to delete a rblist. While rblist__delete() will free the pointer of rblist at the end. It's an inconvenience for the user to delete a rblist which is not allocated by something like malloc(). For example, the rblist is embedded in a larger data structure. This patch creates a new function rblist__exit() which is similar to rblist__delete() but it will not free the pointer of rblist. Signed-off-by: Jin Yao Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Kan Liang Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1512125856-22056-2-git-send-email-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/rblist.c | 19 ++++++++++++------- tools/perf/util/rblist.h | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/rblist.c b/tools/perf/util/rblist.c index 0dfe27d..0efc325 100644 --- a/tools/perf/util/rblist.c +++ b/tools/perf/util/rblist.c @@ -101,16 +101,21 @@ void rblist__init(struct rblist *rblist) return; } +void rblist__exit(struct rblist *rblist) +{ + struct rb_node *pos, *next = rb_first(&rblist->entries); + + while (next) { + pos = next; + next = rb_next(pos); + rblist__remove_node(rblist, pos); + } +} + void rblist__delete(struct rblist *rblist) { if (rblist != NULL) { - struct rb_node *pos, *next = rb_first(&rblist->entries); - - while (next) { - pos = next; - next = rb_next(pos); - rblist__remove_node(rblist, pos); - } + rblist__exit(rblist); free(rblist); } } diff --git a/tools/perf/util/rblist.h b/tools/perf/util/rblist.h index 4c8638a..76df15c 100644 --- a/tools/perf/util/rblist.h +++ b/tools/perf/util/rblist.h @@ -29,6 +29,7 @@ struct rblist { }; void rblist__init(struct rblist *rblist); +void rblist__exit(struct rblist *rblist); void rblist__delete(struct rblist *rblist); int rblist__add_node(struct rblist *rblist, const void *new_entry); void rblist__remove_node(struct rblist *rblist, struct rb_node *rb_node);