<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[SysFreeString called twice?]]></title><description><![CDATA[<p>Hi @all,</p>
<p>ich mache seit lägerer Zeit mal wieder COM und dort wiedermal die häßlichen BSTR - Strings. Ich benutze aber lieber die Wrapper ala _bstr_t um mir das Aufräumen zu sparen.</p>
<p>angenommen ich habe eine Funktion:</p>
<pre><code>void doSomeThing( BSTR strBlub )
{
  //assume something usefull would be done here... 
  SysFreeString(strBlub);
}

{
  _bstr_t strString = &quot;SomeString&quot;;
  doSomeThing( strString );
}//here dtor of _bstr_t is called -&gt; so I assume SysFreeString is called twice...
</code></pre>
<p>..wie beschrieben : ist das legal? Zumindest funktioniert es. Ich habe auch selber mal versucht, was passiert, wenn ich, mehrmals SysFreeString aufrufe - offenbar ist das auch kein Problem. Leider ist die Doku zu SysFreeString sehr dürftig. Ein delete scheint es jedenfalls nicht zu machen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Danke und Viele Grüße,</p>
<p>Tobias</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/191873/sysfreestring-called-twice</link><generator>RSS for Node</generator><lastBuildDate>Wed, 01 Jul 2026 03:08:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/191873.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 07 Sep 2007 14:35:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to SysFreeString called twice? on Fri, 07 Sep 2007 14:36:42 GMT]]></title><description><![CDATA[<p>Hi @all,</p>
<p>ich mache seit lägerer Zeit mal wieder COM und dort wiedermal die häßlichen BSTR - Strings. Ich benutze aber lieber die Wrapper ala _bstr_t um mir das Aufräumen zu sparen.</p>
<p>angenommen ich habe eine Funktion:</p>
<pre><code>void doSomeThing( BSTR strBlub )
{
  //assume something usefull would be done here... 
  SysFreeString(strBlub);
}

{
  _bstr_t strString = &quot;SomeString&quot;;
  doSomeThing( strString );
}//here dtor of _bstr_t is called -&gt; so I assume SysFreeString is called twice...
</code></pre>
<p>..wie beschrieben : ist das legal? Zumindest funktioniert es. Ich habe auch selber mal versucht, was passiert, wenn ich, mehrmals SysFreeString aufrufe - offenbar ist das auch kein Problem. Leider ist die Doku zu SysFreeString sehr dürftig. Ein delete scheint es jedenfalls nicht zu machen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Danke und Viele Grüße,</p>
<p>Tobias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1360865</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1360865</guid><dc:creator><![CDATA[TheBigW]]></dc:creator><pubDate>Fri, 07 Sep 2007 14:36:42 GMT</pubDate></item><item><title><![CDATA[Reply to SysFreeString called twice? on Fri, 07 Sep 2007 15:52:37 GMT]]></title><description><![CDATA[<p><a href="http://msdn2.microsoft.com/en-us/library/ms221481.aspx" rel="nofollow">http://msdn2.microsoft.com/en-us/library/ms221481.aspx</a></p>
<p>=&gt; If bstr is NULL, the function simply returns.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1360916</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1360916</guid><dc:creator><![CDATA[a]]></dc:creator><pubDate>Fri, 07 Sep 2007 15:52:37 GMT</pubDate></item><item><title><![CDATA[Reply to SysFreeString called twice? on Fri, 07 Sep 2007 16:07:49 GMT]]></title><description><![CDATA[<p>wunderbar, ist aber nix neues und hat mit meiner Frage wohl eher nichts zu tun. In dem Fall ist es eben nicht null.</p>
<p>folgendes Negativbeispiel funktioniert erschreckenderweise übrigens auch problemlos:</p>
<pre><code>strProc[0] = 'T';
SysFreeString( strProc );
strProc[0] = 'K';
SysFreeString( strProc );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1360922</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1360922</guid><dc:creator><![CDATA[TheBigW]]></dc:creator><pubDate>Fri, 07 Sep 2007 16:07:49 GMT</pubDate></item><item><title><![CDATA[Reply to SysFreeString called twice? on Fri, 07 Sep 2007 18:07:34 GMT]]></title><description><![CDATA[<p>Du darfst sowas natürlich *nicht* machen!<br />
Du kannst auch mal den Debug-Heap aktivieren (gflags.exe), der wird Dir vermutlich eine Exception um die Ohren werfen... (oder auch das Application-Compatibility-Toolkit).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1360991</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1360991</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Fri, 07 Sep 2007 18:07:34 GMT</pubDate></item><item><title><![CDATA[Reply to SysFreeString called twice? on Sun, 09 Sep 2007 20:32:44 GMT]]></title><description><![CDATA[<p>d.h. also, das in dem Fall, wo in einer Komponente der BSTR intern mit SysFreeString freigegeben wird sind für mich die bstr_t und CComBSTR tabu und ich muß mit AllocSysString und Co. herumhantieren?<br />
Wenn das halt so ist ist es halt so. Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1362213</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1362213</guid><dc:creator><![CDATA[TheBigW]]></dc:creator><pubDate>Sun, 09 Sep 2007 20:32:44 GMT</pubDate></item></channel></rss>