public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: John Love-Jensen <eljay@adobe.com>
To: Glover George <dime@gulfsales.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Classic C problems, need help!
Date: Fri, 03 May 2002 10:50:00 -0000	[thread overview]
Message-ID: <3CD2CDC5.7DC1C137@adobe.com> (raw)
In-Reply-To: <000001c1f2c9$ee002620$0300a8c0@yellow>

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


  reply	other threads:[~2002-05-03 17:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-03 10:38 Glover George
2002-05-03 10:50 ` John Love-Jensen [this message]
2002-05-03 11:35   ` Glover George
2002-05-05  5:34 ` Sebastian Huber
2002-05-03 11:44 Kári Davíðsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3CD2CDC5.7DC1C137@adobe.com \
    --to=eljay@adobe.com \
    --cc=dime@gulfsales.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).