From patchwork Thu Apr 14 19:41:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 91287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 764D7B6FDF for ; Fri, 15 Apr 2011 05:42:37 +1000 (EST) Received: (qmail 24754 invoked by alias); 14 Apr 2011 19:42:36 -0000 Received: (qmail 24746 invoked by uid 22791); 14 Apr 2011 19:42:35 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (140.186.70.92) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Apr 2011 19:42:29 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QASQu-0004Y6-F0 for gcc-patches@gcc.gnu.org; Thu, 14 Apr 2011 15:42:29 -0400 Received: from smtp-out.google.com ([74.125.121.67]:19302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QASQu-0004Xs-6n for gcc-patches@gcc.gnu.org; Thu, 14 Apr 2011 15:42:28 -0400 Received: from wpaz29.hot.corp.google.com (wpaz29.hot.corp.google.com [172.24.198.93]) by smtp-out.google.com with ESMTP id p3EJfhxU011972; Thu, 14 Apr 2011 12:41:43 -0700 Received: from topo.tor.corp.google.com (topo.tor.corp.google.com [172.29.41.2]) by wpaz29.hot.corp.google.com with ESMTP id p3EJfgWn003397; Thu, 14 Apr 2011 12:41:42 -0700 Received: by topo.tor.corp.google.com (Postfix, from userid 54752) id F3BA2A00D; Thu, 14 Apr 2011 15:41:41 -0400 (EDT) To: reply@codereview.appspotmail.com, crowl@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Rebuild compilation context from PPH images (5/6) (issue4410045) Message-Id: <20110414194141.F3BA2A00D@topo.tor.corp.google.com> Date: Thu, 14 Apr 2011 15:41:41 -0400 (EDT) From: dnovillo@google.com (Diego Novillo) X-System-Of-Record: true X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 74.125.121.67 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch factors out the allocation of sorted_fields_type into a new function so it can be called from the PPH reader. * class.c (sorted_fields_type_new): Factor out of ... (finish_struct_1): ... here. --- This patch is available for review at http://codereview.appspot.com/4410045 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 1325260..b040449 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5536,6 +5536,18 @@ determine_key_method (tree type) return; } + +/* Allocate and return an instance of struct sorted_fields_type with + N fields. */ + +struct sorted_fields_type * +sorted_fields_type_new (int n) +{ + return ggc_alloc_sorted_fields_type (sizeof (struct sorted_fields_type) + + n * sizeof (tree)); +} + + /* Perform processing required when the definition of T (a class type) is complete. */ @@ -5665,8 +5677,7 @@ finish_struct_1 (tree t) n_fields = count_fields (TYPE_FIELDS (t)); if (n_fields > 7) { - struct sorted_fields_type *field_vec = ggc_alloc_sorted_fields_type - (sizeof (struct sorted_fields_type) + n_fields * sizeof (tree)); + struct sorted_fields_type *field_vec = sorted_fields_type_new (n_fields); field_vec->len = n_fields; add_fields_to_record_type (TYPE_FIELDS (t), field_vec, 0); qsort (field_vec->elts, n_fields, sizeof (tree),