<?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[Wieder mal Debug Assertion failed...]]></title><description><![CDATA[<p>Hi,</p>
<p>Ich hab zwar keine Frage zur MFC, mehr zu Visual C++. Mein Programm verursacht o.g. Fehler (genauer:<br />
File: dbgheap.c<br />
Line: 1017</p>
<p>Expression: _BLOCK_TYPE_IS_VALID(pHead.&gt;nBlockUse)<br />
).<br />
Und zwar hab ich ein dynamisches Feld: lpSprList. Über eine weitere Variable iAnzSprList wird festgelegt, wie groß dieses Feld ist. Ist jetzt iAnsSprList == 0 und ich möchte infolgedessen lpSprList freigeben, kommt der Fehler oben (nicht wenn ich versuche, danach auf lpSprList zuzugreifen (also keine Zugriffsverletzung) ).</p>
<p>Hier die Funktion.</p>
<pre><code class="language-cpp">BOOL momSpriteListe_EintragLoeschen(LPMOM_LEVELPROJEKT lpAktuellesProjekt, int iIndexSpr)
{
	int							i;
	LPMOM_SPRITE				lpSpriteTmp;

	lpAktuellesProjekt-&gt;Level.iAnzSpr--;

	if(lpAktuellesProjekt-&gt;Level.iAnzSpr == 0)
	{
	free(lpAktuellesProjekt-&gt;Level.lpSprListe);  // HIER KLINGELT'S !!!
	lpAktuellesProjekt-&gt;Level.lpSprListe = NULL;

		return TRUE;
	}

// DER VOLLSTÄNDIGKEIT HALBER NOCH DER REST DER FUNKTION:
	lpSpriteTmp		= (LPMOM_SPRITE) calloc(sizeof(MOM_SPRITE),lpAktuellesProjekt-&gt;Level.iAnzSpr);
		if(!lpSpriteTmp) return FALSE;

	i = iIndexSpr;
	while( i &lt; (lpAktuellesProjekt-&gt;Level.iAnzSpr) )
	{
		lpAktuellesProjekt-&gt;Level.lpSprListe[i] = lpAktuellesProjekt-&gt;Level.lpSprListe[i+1];
		i++;
	}

	for(i = 0; i &lt; lpAktuellesProjekt-&gt;Level.iAnzSpr; i++)
	{
		lpSpriteTmp[i]	= lpAktuellesProjekt-&gt;Level.lpSprListe[i];
	}

	free(lpAktuellesProjekt-&gt;Level.lpSprListe);
	free(lpAktuellesProjekt-&gt;lpPfadTab);

	lpAktuellesProjekt-&gt;Level.lpSprListe	= lpSpriteTmp;
	lpAktuellesProjekt-&gt;lpPfadTab			= lpPfadTabTmp;

	return TRUE;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/67377/wieder-mal-debug-assertion-failed</link><generator>RSS for Node</generator><lastBuildDate>Sat, 06 Jun 2026 08:30:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/67377.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 07 Mar 2004 21:17:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wieder mal Debug Assertion failed... on Sun, 07 Mar 2004 21:17:44 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>Ich hab zwar keine Frage zur MFC, mehr zu Visual C++. Mein Programm verursacht o.g. Fehler (genauer:<br />
File: dbgheap.c<br />
Line: 1017</p>
<p>Expression: _BLOCK_TYPE_IS_VALID(pHead.&gt;nBlockUse)<br />
).<br />
Und zwar hab ich ein dynamisches Feld: lpSprList. Über eine weitere Variable iAnzSprList wird festgelegt, wie groß dieses Feld ist. Ist jetzt iAnsSprList == 0 und ich möchte infolgedessen lpSprList freigeben, kommt der Fehler oben (nicht wenn ich versuche, danach auf lpSprList zuzugreifen (also keine Zugriffsverletzung) ).</p>
<p>Hier die Funktion.</p>
<pre><code class="language-cpp">BOOL momSpriteListe_EintragLoeschen(LPMOM_LEVELPROJEKT lpAktuellesProjekt, int iIndexSpr)
{
	int							i;
	LPMOM_SPRITE				lpSpriteTmp;

	lpAktuellesProjekt-&gt;Level.iAnzSpr--;

	if(lpAktuellesProjekt-&gt;Level.iAnzSpr == 0)
	{
	free(lpAktuellesProjekt-&gt;Level.lpSprListe);  // HIER KLINGELT'S !!!
	lpAktuellesProjekt-&gt;Level.lpSprListe = NULL;

		return TRUE;
	}

// DER VOLLSTÄNDIGKEIT HALBER NOCH DER REST DER FUNKTION:
	lpSpriteTmp		= (LPMOM_SPRITE) calloc(sizeof(MOM_SPRITE),lpAktuellesProjekt-&gt;Level.iAnzSpr);
		if(!lpSpriteTmp) return FALSE;

	i = iIndexSpr;
	while( i &lt; (lpAktuellesProjekt-&gt;Level.iAnzSpr) )
	{
		lpAktuellesProjekt-&gt;Level.lpSprListe[i] = lpAktuellesProjekt-&gt;Level.lpSprListe[i+1];
		i++;
	}

	for(i = 0; i &lt; lpAktuellesProjekt-&gt;Level.iAnzSpr; i++)
	{
		lpSpriteTmp[i]	= lpAktuellesProjekt-&gt;Level.lpSprListe[i];
	}

	free(lpAktuellesProjekt-&gt;Level.lpSprListe);
	free(lpAktuellesProjekt-&gt;lpPfadTab);

	lpAktuellesProjekt-&gt;Level.lpSprListe	= lpSpriteTmp;
	lpAktuellesProjekt-&gt;lpPfadTab			= lpPfadTabTmp;

	return TRUE;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/475345</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/475345</guid><dc:creator><![CDATA[achim2310]]></dc:creator><pubDate>Sun, 07 Mar 2004 21:17:44 GMT</pubDate></item><item><title><![CDATA[Reply to Wieder mal Debug Assertion failed... on Sun, 07 Mar 2004 22:53:21 GMT]]></title><description><![CDATA[<p>Sorry, es gab einen Fehler beim Frstellen des Feldes (in einer anderen Funktion). Jetzt klappts... kann jemand diesen Thread löschen :p ??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/475401</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/475401</guid><dc:creator><![CDATA[achim2310]]></dc:creator><pubDate>Sun, 07 Mar 2004 22:53:21 GMT</pubDate></item></channel></rss>