<?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[Speicher Problem (Dynamisch)]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe ja schonmal meine Klasse hier gepostet da ich Hilfe von euch brauchte <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>Jetzt ist es wieder soweit wo ich net weiter komme, hier der Code als beispiel:</p>
<pre><code>#include &lt;iostream&gt; 
void speicherint (int txt);
void verschlüsselint (int txt);

int main() 
{
   int n = 20;
   speicherint (n);
   return 0;
}

void speicherint (int txt)
{
	int *ptr = new int;
	*ptr = txt;
	verschlüsselint (*ptr);
	delete ptr;
	*ptr = NULL;
}

void verschlüsselint (int txt)
{
	int i = txt;
}
</code></pre>
<p>Das Problem ist, das ich beim *ptr = NULL ein Error bekomme, wenn ich es umdrehe sprich erst auf NULL setzen, dann delete, bekomme ich kein Error, was aber ein Memory leak ist oder?</p>
<p>Warum bekomme ich den fehler? was ist da falsch?</p>
<p>Wenn ich alles zusammen hab und es Compiliere, bekomme ich das zusehen:</p>
<pre><code>void __cdecl _free_base (void * pBlock)
{

        int retval = 0;

        if (pBlock == NULL)
            return;

        RTCCALLBACK(_RTC_Free_hook, (pBlock, 0));

        retval = HeapFree(_crtheap, 0, pBlock);
        if (retval == 0)
        {
            errno = _get_errno_from_oserr(GetLastError());
        }
}
</code></pre>
<p>Aber da bekomme ich den fehler, obwohl er schon längst raus ist aus der funktion mit dem dynamischen speicher, warum?</p>
<p>Bitte um Hilfe.</p>
<p>mfg</p>
<p>Kai</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/317186/speicher-problem-dynamisch</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Jul 2026 11:26:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/317186.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 May 2013 12:14:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Speicher Problem (Dynamisch) on Thu, 30 May 2013 12:15:09 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe ja schonmal meine Klasse hier gepostet da ich Hilfe von euch brauchte <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>Jetzt ist es wieder soweit wo ich net weiter komme, hier der Code als beispiel:</p>
<pre><code>#include &lt;iostream&gt; 
void speicherint (int txt);
void verschlüsselint (int txt);

int main() 
{
   int n = 20;
   speicherint (n);
   return 0;
}

void speicherint (int txt)
{
	int *ptr = new int;
	*ptr = txt;
	verschlüsselint (*ptr);
	delete ptr;
	*ptr = NULL;
}

void verschlüsselint (int txt)
{
	int i = txt;
}
</code></pre>
<p>Das Problem ist, das ich beim *ptr = NULL ein Error bekomme, wenn ich es umdrehe sprich erst auf NULL setzen, dann delete, bekomme ich kein Error, was aber ein Memory leak ist oder?</p>
<p>Warum bekomme ich den fehler? was ist da falsch?</p>
<p>Wenn ich alles zusammen hab und es Compiliere, bekomme ich das zusehen:</p>
<pre><code>void __cdecl _free_base (void * pBlock)
{

        int retval = 0;

        if (pBlock == NULL)
            return;

        RTCCALLBACK(_RTC_Free_hook, (pBlock, 0));

        retval = HeapFree(_crtheap, 0, pBlock);
        if (retval == 0)
        {
            errno = _get_errno_from_oserr(GetLastError());
        }
}
</code></pre>
<p>Aber da bekomme ich den fehler, obwohl er schon längst raus ist aus der funktion mit dem dynamischen speicher, warum?</p>
<p>Bitte um Hilfe.</p>
<p>mfg</p>
<p>Kai</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2327338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2327338</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 30 May 2013 12:15:09 GMT</pubDate></item><item><title><![CDATA[Reply to Speicher Problem (Dynamisch) on Thu, 30 May 2013 12:25:20 GMT]]></title><description><![CDATA[<p>weil du mit *ptr auf Speicher zugreifst, den du in der Zeile vorher freigegeben hast. Was du wolltest ist ptr = NULL und was du eigentlich willst ist:</p>
<pre><code class="language-cpp">void speicherint (int txt)
{
    verschlüsselint (txt);
}
</code></pre>
<p>Das macht nämlich exakt das gleiche.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2327339</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2327339</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Thu, 30 May 2013 12:25:20 GMT</pubDate></item><item><title><![CDATA[Reply to Speicher Problem (Dynamisch) on Thu, 30 May 2013 13:04:53 GMT]]></title><description><![CDATA[<p>ahh thx <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="🙂"
    /> oh man bin ich fail ja^^ hätte ich auch selbst drauf kommen können xDD bin ich aber net <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="🙂"
    /><br />
thx</p>
<p>Jetzt funzt das auch alles <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>
]]></description><link>https://www.c-plusplus.net/forum/post/2327345</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2327345</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 30 May 2013 13:04:53 GMT</pubDate></item></channel></rss>