From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21738 invoked by alias); 3 May 2002 17:50:13 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 21711 invoked from network); 3 May 2002 17:50:07 -0000 Received: from unknown (HELO smtp-relay-3.sea.adobe.com) (192.150.22.10) by sources.redhat.com with SMTP; 3 May 2002 17:50:07 -0000 Received: from inner-relay-3.corp.adobe.com (inner-relay-3 [153.32.251.51]) by smtp-relay-3.sea.adobe.com (8.12.3/8.12.3) with ESMTP id g43HnLpo010162 for ; Fri, 3 May 2002 10:49:21 -0700 (PDT) Received: from iplan-mn.corp.adobe.com (iplan-mn.corp.adobe.com [130.248.25.5]) by inner-relay-3.corp.adobe.com (8.12.3/8.12.3) with ESMTP id g43HlPQG026905 for ; Fri, 3 May 2002 10:47:25 -0700 (PDT) Received: from adobe.com ([130.248.184.129]) by iplan-mn.corp.adobe.com (Netscape Messaging Server 4.15 mn Jul 11 2001 16:32:57) with ESMTP id GVJQVO00.AOP; Fri, 3 May 2002 12:50:12 -0500 Message-ID: <3CD2CDC5.7DC1C137@adobe.com> Date: Fri, 03 May 2002 10:50:00 -0000 From: John Love-Jensen X-Accept-Language: en MIME-Version: 1.0 To: Glover George CC: gcc-help@gcc.gnu.org Subject: Re: Classic C problems, need help! References: <000001c1f2c9$ee002620$0300a8c0@yellow> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-05/txt/msg00023.txt.bz2 Hi Dime, What you are running into is the concept known as OWNERSHIP. I put OWNERSHIP in capitals because it is a very important C/C++ detail to get right -- otherwise memory leaks or dangling pointers, then Bad Things Happen shortly thereafter. Aside: Java gets around the OWNERSHIP problem by having garbage collection, pass-by-value for POD and pass-by-reference for UDT. When you pass the char* to the other routine, does it's contract say that it is taking OWNERSHIP of that string? And thus, is responsible to destruct it, when appropriate. Or does that other routine merely borrow that string for whatever purposes... input only? output only? input/output (aka update)? utility or functor (more so for C++ than C)? Without known the contract that the routine is operating under, I cannot tell you your proper course of action. --Eljay