From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13515 invoked by alias); 12 Sep 2008 15:13:29 -0000 Received: (qmail 13504 invoked by uid 22791); 12 Sep 2008 15:13:28 -0000 X-Spam-Check-By: sourceware.org Received: from smtp.nokia.com (HELO mgw-mx06.nokia.com) (192.100.122.233) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 12 Sep 2008 15:12:54 +0000 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx06.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id m8CFCNfj005182 for ; Fri, 12 Sep 2008 18:12:49 +0300 Received: from vaebh102.NOE.Nokia.com ([10.160.244.23]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 12 Sep 2008 18:12:35 +0300 Received: from gar.local ([172.25.167.168]) by vaebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Fri, 12 Sep 2008 18:12:29 +0300 From: =?iso-8859-1?q?Andr=E9_P=F6nitz?= To: gdb@sources.redhat.com Subject: gdb sources Date: Fri, 12 Sep 2008 15:13:00 -0000 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200809121713.09226.apoenitz@trolltech.com> X-Nokia-AV: Clean X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-09/txt/msg00070.txt.bz2 Hi all. I browsed a bit through gdb sources and came across a few question I can not answer. Maybe some kind soul can help ;-) (1) There is e.g. static void make_command (const char *arg, int from_tty) { char *p; if (arg == 0) p = "make"; else { p = xmalloc (sizeof ("make ") + strlen (arg)); strcpy (p, "make "); strcpy (p + sizeof ("make ") - 1, arg); } shell_escape (p, from_tty); } In one branch, p points to a literal, in the other to the heap. shell_escape() does not seem to release any memory (would also be wrong in the literal case...), so if the else branch is taken it's a leak, no? (2) Most of the "strings" in gdb are "char *", even if they are conceptionally "const char *" (i.e. coming from literal, or not intended to be changed). Why? In some places "const" is also used, so the reason can't be "gdb supports compilers that don't know about 'const'". Is it "just legacy"? If so, would patches replacing "char *" by "const char *" if appropriate be welcome? (3) Most of the declarations in command.h are repeated in cli/cli-decode.h even though cli-decode.h #include's command.h. Couldn't the duplicates just be removed? Andre'