Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1233647imm; Tue, 5 Jun 2018 11:05:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLynBnI/aAZytjTpry1C7P7pDfsOHMc2mG8uzvERJYSeVtuPZ6r17T8QqG5iq8hLH4NWIy2 X-Received: by 2002:a17:902:3303:: with SMTP id a3-v6mr27523184plc.209.1528221951622; Tue, 05 Jun 2018 11:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528221951; cv=none; d=google.com; s=arc-20160816; b=c6wfiitLhTnmWf7b8JhiwM+UFSJMt3nH5CPHNalmaI6il8A9iWCFJ4cTdnNiqdRlPb p7wih5MoA8LjW9RdLdrjuMMYpwmYPOFTnxAWN7DJeBENSvw6HFatideRINxOW8xZgQzY Nul7jURIPPbvR2jj++eKN2Tma5J1HtownU+3bFwpvOARnoB2tL3Mpez7BW6+6KwU1wD+ mQplMIjM2QVeBhKQtb9LfsUXibhsggi/zcrkkmz6j3rAox29xOMgzos5JotyaXQWJvzZ CvJ5RX4UI12u6vVA1nngexcXv8HvFOzVVx0emhGkei1CdJf4XTQt290BzMiLovgPXVIo NEJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=8Ghkut8JZ/JcTywgonj0aiJH9wZdNGm4fzSTtjaEono=; b=mr8syMcnSmqKmL6gJ4aPGK7TIOeJ8IkaZdg2+GCqy8CkIRa5Ergn0N4sKi536HrYWl kvPCsynkn1GPGSsdaVRF6y5ExlmkQXO65KpHMFcaz2+Ug3nNUPhLMXbBpngoSb0LI/Mi srzB+he7/zpXatvtOZl0Q8qC6ODvw+xYK9LLzec/XMsKFshKEtvLNL9P5lzaG0dyxbhT /U/e8i1JrQyd3A2pIkqWUdT0IvSpJ4H8G0TMshR5JFzwez33ijdlVSZXOK+rc3L5ivXz Nj9Ukpw2WNn9/ULMCtToyyzOJVSNFowjtAGy9oxLDBsAjKW/D1FCyYxc9grbWkU24sP8 K/lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bLKi9Y3U; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3-v6si48534818pld.513.2018.06.05.11.05.37; Tue, 05 Jun 2018 11:05:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bLKi9Y3U; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752177AbeFERvK (ORCPT + 99 others); Tue, 5 Jun 2018 13:51:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:45624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752113AbeFERvG (ORCPT ); Tue, 5 Jun 2018 13:51:06 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 461142087F; Tue, 5 Jun 2018 17:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528221065; bh=AwImeJwc4FN1IoeX4EcDD2c0sYEk2L8Z+vSp0mIrlfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bLKi9Y3Uk1kFDnpe6d+amn6s9vIzwhK7PxzsOonSNU8OQ5QTOi64eXty9wzPnpVYt bqLZqqiRTi1hkVNv2Y2ZrzhidSWRC0s25pTAXo/pa8biyGrzZcbLEgizoRI+6CE+G5 fO5Z72U1IJXGDspymVONUnNdk7WvLuBrkqRkFG1I= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Jiri Olsa , Namhyung Kim , Wang Nan Subject: [PATCH 08/46] perf annotate: Introduce constructor/destructor for annotated_source Date: Tue, 5 Jun 2018 14:49:52 -0300 Message-Id: <20180605175030.32549-9-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180605175030.32549-1-acme@kernel.org> References: <20180605175030.32549-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo More stuff will go in there, all the parts that are not needed when a symbol had no samples and that were mistakenly added to 'struct annotation'. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-u4761kyzhixw9ydk6kib3f0o@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index f0c6941bca6c..f6c9bb29ac84 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -678,6 +678,25 @@ static struct arch *arch__find(const char *name) return bsearch(name, architectures, nmemb, sizeof(struct arch), arch__key_cmp); } +static struct annotated_source *annotated_source__new(void) +{ + struct annotated_source *src = zalloc(sizeof(*src)); + + if (src != NULL) + INIT_LIST_HEAD(&src->source); + + return src; +} + +static void annotated_source__delete(struct annotated_source *src) +{ + if (src == NULL) + return; + zfree(&src->histograms); + zfree(&src->cycles_hist); + free(src); +} + int symbol__alloc_hist(struct symbol *sym) { struct annotation *notes = symbol__annotation(sym); @@ -704,17 +723,17 @@ int symbol__alloc_hist(struct symbol *sym) if (sizeof_sym_hist > SIZE_MAX / symbol_conf.nr_events) return -1; - notes->src = zalloc(sizeof(*notes->src)); + notes->src = annotated_source__new(); if (notes->src == NULL) return -1; notes->src->histograms = calloc(symbol_conf.nr_events, sizeof_sym_hist); if (notes->src->histograms == NULL) { - zfree(¬es->src); + annotated_source__delete(notes->src); + notes->src = NULL; return -1; } notes->src->sizeof_sym_hist = sizeof_sym_hist; notes->src->nr_histograms = symbol_conf.nr_events; - INIT_LIST_HEAD(¬es->src->source); return 0; } -- 2.14.3