From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53389 invoked by alias); 19 Oct 2016 23:08:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 53367 invoked by uid 89); 19 Oct 2016 23:08:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.2 required=5.0 tests=AWL,BAYES_50,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=Hx-languages-length:1517, H*r:112, freeing, sk:object X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Oct 2016 23:08:42 +0000 Received: by simark.ca (Postfix, from userid 112) id B9A6E1E486; Wed, 19 Oct 2016 19:08:40 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 943091E124; Wed, 19 Oct 2016 19:08:39 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 19 Oct 2016 23:08:00 -0000 From: Simon Marchi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2 21/31] Use ui_file_as_string in gdb/compile/ In-Reply-To: <1476839539-8374-22-git-send-email-palves@redhat.com> References: <1476839539-8374-1-git-send-email-palves@redhat.com> <1476839539-8374-22-git-send-email-palves@redhat.com> Message-ID: <8a267925d9af7f5b01c75a81da15b664@simark.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.0 X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00592.txt.bz2 The doc for get_new_file_names should probably be updated: /* Compute the names of source and object files to use. The names are allocated by malloc and should be freed by the caller. */ > static void > -get_new_file_names (char **source_file, char **object_file) > +get_new_file_names (std::string *source_file, std::string > *object_file) > { Same for compile_to_object, both for the "freeing" part and the part that talks about the return value. We should use $other_language instead of C++, to be able to do source_filep, object_filep = compile_to_object (...) :) Btw, would it be good to use references for those strings? > error condition, error () is called. The caller is responsible for > freeing both strings. */ > > -static char * > +static void > compile_to_object (struct command_line *cmd, const char *cmd_string, > enum compile_i_scope_types scope, > - char **source_filep) > + std::string *source_filep, > + std::string *object_filep) > { ... > @@ -609,30 +606,27 @@ void > eval_compile_command (struct command_line *cmd, const char > *cmd_string, > enum compile_i_scope_types scope, void *scope_data) > { > - char *object_file, *source_file; > + std::string source_file, object_file; > > - object_file = compile_to_object (cmd, cmd_string, scope, > &source_file); > - if (object_file != NULL) > + compile_to_object (cmd, cmd_string, scope, &source_file, > &object_file); > + if (!object_file.empty ()) Can this actually happen?