From patchwork Thu Jun 30 01:37:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gab Charette X-Patchwork-Id: 102691 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 3A8BBB6F59 for ; Thu, 30 Jun 2011 11:38:17 +1000 (EST) Received: (qmail 25023 invoked by alias); 30 Jun 2011 01:38:15 -0000 Received: (qmail 25015 invoked by uid 22791); 30 Jun 2011 01:38:14 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Jun 2011 01:38:00 +0000 Received: from kpbe12.cbf.corp.google.com (kpbe12.cbf.corp.google.com [172.25.105.76]) by smtp-out.google.com with ESMTP id p5U1bwwk017078; Wed, 29 Jun 2011 18:37:58 -0700 Received: from gchare.mtv.corp.google.com (gchare.mtv.corp.google.com [172.18.111.122]) by kpbe12.cbf.corp.google.com with ESMTP id p5U1bujD006367; Wed, 29 Jun 2011 18:37:56 -0700 Received: by gchare.mtv.corp.google.com (Postfix, from userid 138564) id 4ED981C1480; Wed, 29 Jun 2011 18:37:56 -0700 (PDT) To: reply@codereview.appspotmail.com, crowl@google.com, dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Fixing string streaming functions and their comments (issue4654076) Message-Id: <20110630013756.4ED981C1480@gchare.mtv.corp.google.com> Date: Wed, 29 Jun 2011 18:37:56 -0700 (PDT) From: gchare@google.com (Gabriel Charette) X-System-Of-Record: true 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 Some comments were wrong. In particular, the strings read from the stream are placed in a data table, and thus the strings returned DO NOT need to be freed by the caller, they belong to the stream who handles them itself. Also lto_output_string_with_length does handle NULL strings, removed the redundant logic. Tested with bootstrap build and pph regression testing. 2011-06-29 Gabriel Charette * pph-streamer.h (struct pph_stream): Fix comment of data_in field. (pph_out_string_with_length): lto_output_string_with_length now handles NULL strings, call it directly. (pph_in_string): Fix comment. --- This patch is available for review at http://codereview.appspot.com/4654076 diff --git a/gcc/cp/pph-streamer.h b/gcc/cp/pph-streamer.h index b899501..8d0c024 100644 --- a/gcc/cp/pph-streamer.h +++ b/gcc/cp/pph-streamer.h @@ -100,7 +100,7 @@ typedef struct pph_stream { struct lto_input_block *ib; /* String tables and other descriptors used by the LTO reading - routines. NULL when the file is opened for reading. */ + routines. NULL when the file is opened for writing. */ struct data_in *data_in; /* Array of sections in the PPH file. */ @@ -250,21 +250,10 @@ static inline void pph_out_string_with_length (pph_stream *stream, const char *str, unsigned int len) { - if (str) - { - if (flag_pph_tracer >= 4) - pph_trace_string_with_length (stream, str, len); - lto_output_string_with_length (stream->ob, stream->ob->main_stream, - str, len + 1, false); - } - else - { - /* lto_output_string_with_length does not handle NULL strings, - but lto_output_string does. */ - if (flag_pph_tracer >= 4) - pph_trace_string (stream, str); - pph_out_string (stream, NULL); - } + if (flag_pph_tracer >= 4) + pph_trace_string_with_length (stream, str, len); + lto_output_string_with_length (stream->ob, stream->ob->main_stream, + str, len + 1, false); } /* Output VEC V of ASTs to STREAM. @@ -338,9 +327,7 @@ pph_in_bytes (pph_stream *stream, void *p, size_t n) pph_trace_bytes (stream, p, n); } -/* Read and return a string of up to MAX characters from STREAM. - The caller is responsible for freeing the memory allocated - for the string. */ +/* Read and return a string of up to MAX characters from STREAM. */ static inline const char * pph_in_string (pph_stream *stream)