<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: AcString? in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6714134#M9191</link>
    <description>&lt;P&gt;After return from this function destructor of "c" do returned pointer invalid. You do not use such code. IMHO.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2016 21:13:48 GMT</pubDate>
    <dc:creator>Alexander.Rivilis</dc:creator>
    <dc:date>2016-11-28T21:13:48Z</dc:date>
    <item>
      <title>AcString?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6714103#M9190</link>
      <description>&lt;PRE&gt;const ACHAR* WhatIsReturned()
{
      AcString a = L"Test";
      AcString b = L" this";
      AcString c = a + b;&lt;BR /&gt;      return c;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;What happens to c when this method returns. Does the underlying string encapsulated by c get lost when c goes out of scope or is a copy of the const ACHAR* returned?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 21:01:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6714103#M9190</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-28T21:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: AcString?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6714134#M9191</link>
      <description>&lt;P&gt;After return from this function destructor of "c" do returned pointer invalid. You do not use such code. IMHO.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 21:13:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6714134#M9191</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-11-28T21:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: AcString?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6714598#M9192</link>
      <description>&lt;P&gt;Memory for&amp;nbsp;all three local&amp;nbsp;strings is freed before the function returns. The code is not correct.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 01:22:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6714598#M9192</guid>
      <dc:creator>owenwengerd</dc:creator>
      <dc:date>2016-11-29T01:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: AcString?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6715470#M9193</link>
      <description>&lt;P&gt;Yeah, I figured as much, but I was thinking that one of the overloads would return a new ACHAR*. I realized after I posted that this was a "cloudy mind moment" realizing that even if a new ACHAR* was returned, there was no way to free it. Will a AcString be returned by value? Or would that be freed as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;AcString TestThis()
{
    AcString a = L"Test";
    AcString b = L" this!";
    AcString c = a + b;

    return c;
}&lt;/PRE&gt;&lt;P&gt;In this code, would 'c' be returned by value or would it still go out of scope?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 12:17:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6715470#M9193</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-29T12:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: AcString?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6715517#M9194</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Yeah, I figured as much, but I was thinking that one of the overloads would return a new ACHAR*. I realized after I posted that this was a "cloudy mind moment" realizing that even if a new ACHAR* was returned, there was no way to free it. Will a AcString be returned by value? Or would that be freed as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;AcString TestThis()
{
    AcString a = L"Test";
    AcString b = L" this!";
    AcString c = a + b;

    return c;
}&lt;/PRE&gt;
&lt;P&gt;In this code, would 'c' be returned by value or would it still go out of scope?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In this code compile create copy of 'c' and return it. After that destructor of 'c' will be called. So you have a valid value of 'c' after calling TestThis():&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;AcString d = TestThis();&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Nov 2016 12:35:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6715517#M9194</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-11-29T12:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: AcString?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6715842#M9195</link>
      <description>&lt;P&gt;It's common to return AcString by value, but&amp;nbsp;functions should almost never accept string arguments as AcString&amp;nbsp;by value. Almost always, string arguments should be typed as &lt;EM&gt;const ACHAR*&lt;/EM&gt; or at least &lt;EM&gt;const AcString&amp;amp;&lt;/EM&gt;. Example (untested):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;AcString myConcatStr1(const ACHAR* in1, const ACHAR* in2)
{
  AcString in1Str(in1);
  return in1Str + in2;
}

AcString myConcatStr2(const AcString&amp;amp; in1Str, const AcString&amp;amp; in2Str)
{
  return in1Str + in2Str;
}

void test()
{
  AcString s1 = _ACRX_T("Test");
  AcString s2 = _ACRX_T(" String");
  AcString s3 = myConcatStr1(s1, s2);
  AcString s4 = myConcatStr2(s1, s2);
}&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Nov 2016 14:36:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acstring/m-p/6715842#M9195</guid>
      <dc:creator>owenwengerd</dc:creator>
      <dc:date>2016-11-29T14:36:46Z</dc:date>
    </item>
  </channel>
</rss>

