• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C++ std::string tries to free() a not allocated pointer ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ std::string tries to free() a not allocated pointer ?


  • Subject: Re: C++ std::string tries to free() a not allocated pointer ?
  • From: David Rowland <email@hidden>
  • Date: Thu, 19 Nov 2009 07:48:59 -0800


On Nov 19, 2009, at 7:41 AM, Howard Moon wrote:


On Nov 19, 2009, at 7:26 AM, Paul Sanders wrote:

What does your destructor do? Your copy constructors / assignment operators
appear to copy the pointer, rather than making a copy of the data pointed
to, so perhaps you end up freeing the pointer twice (once for each SQLString
object destroyed).



That would be true if realStr were a char*. But it's defined as a std::string, so its assignment operator is used, which would perform the string copy properly.



A rule of thumb with C++ is that the assignment operator, copy constructor and destructor tend to come as a package. If you need one, you often need all three. _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: C++ std::string tries to free() a not allocated pointer ?
      • From: Howard Moon <email@hidden>
References: 
 >Re: C++ std::string tries to free() a not allocated pointer ? (From: Robert Schwalbe <email@hidden>)
 >Re: C++ std::string tries to free() a not allocated pointer ? (From: Jean-Denis Muys <email@hidden>)
 >Re: C++ std::string tries to free() a not allocated pointer ? (From: "Paul Sanders" <email@hidden>)
 >Re: C++ std::string tries to free() a not allocated pointer ? (From: Howard Moon <email@hidden>)

  • Prev by Date: setting breakpoints in gdb
  • Next by Date: Re: C++ std::string tries to free() a not allocated pointer ?
  • Previous by thread: Re: C++ std::string tries to free() a not allocated pointer ?
  • Next by thread: Re: C++ std::string tries to free() a not allocated pointer ?
  • Index(es):
    • Date
    • Thread