From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16622 invoked by alias); 3 May 2002 18:35:15 -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 16599 invoked from network); 3 May 2002 18:35:09 -0000 Received: from unknown (HELO gulf.gulfsales.com) (208.164.149.42) by sources.redhat.com with SMTP; 3 May 2002 18:35:09 -0000 Received: (qmail 23057 invoked from network); 3 May 2002 18:35:19 -0000 Received: from dime.gulfsales.com (HELO yellow) (192.168.0.3) by gulf.gulfsales.com with SMTP; 3 May 2002 18:35:19 -0000 From: "Glover George" To: "'John Love-Jensen'" Cc: Subject: RE: Classic C problems, need help! Date: Fri, 03 May 2002 11:35:00 -0000 Message-ID: <000301c1f2d1$dc1d9f20$0300a8c0@yellow> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 In-Reply-To: <3CD2CDC5.7DC1C137@adobe.com> X-SW-Source: 2002-05/txt/msg00024.txt.bz2 I guess that's the problem is how do I know? If the prototype of the function is (char *someval) does that tell me anything? I mean, other than well documented function headers, how do I know? > -----Original Message----- > From: gcc-help-owner@gcc.gnu.org > [mailto:gcc-help-owner@gcc.gnu.org] On Behalf Of John Love-Jensen > Sent: Friday, May 03, 2002 12:50 PM > To: Glover George > Cc: gcc-help@gcc.gnu.org > Subject: Re: Classic C problems, need help! > > > 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 > >