This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Classic C problems, need help!


You don't know.

Welcome to the world of C and C++.

K.D.

> -----Original Message-----
> From: Glover George [mailto:dime@gulfsales.com]
> Sent: 3. maí 2002 18:39
> To: 'John Love-Jensen'
> Cc: gcc-help@gcc.gnu.org
> Subject: RE: Classic C problems, need help!
> 
> 
> 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
> > 
> > 
> 
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]