<?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[Pointer löschen]]></title><description><![CDATA[<p>Hallo zusammen</p>
<p>habe folgendes geschrieben:</p>
<pre><code>time_t currentTime;
    struct tm * timeinfo;

    currentTime = time(NULL);
    timeinfo    = localtime(&amp;currentTime);

    o_currentTime.r_date.i_year         = timeinfo-&gt;tm_year + 1900;
    o_currentTime.r_date.i_month        = timeinfo-&gt;tm_mon  + 1;
    o_currentTime.r_date.i_day          = timeinfo-&gt;tm_mday;

    o_currentTime.r_time.i_hour         = timeinfo-&gt;tm_hour;
    o_currentTime.r_time.i_minute       = timeinfo-&gt;tm_min;
    o_currentTime.r_time.i_seconds      = timeinfo-&gt;tm_sec;
    o_currentTime.r_time.i_milliseconds = 0;

    delete timeinfo;
</code></pre>
<p>Normaerweise muss man doch am ende einer Methode mit den überschüssigen Pointer aufräumen, glaube ich idenenfalls.</p>
<p>Nun habe ich aber ein Problem mit dieser Methode, läuft sie das erste Mal durch hat das System kein Problem, sobald das delete aber zum zweiten mal aufgerufen wird bricht das Prog ab mit folgener Meldung:<br />
&lt;&lt;User breakpoint called from code at 0x77f75a58&gt;&gt;</p>
<p>Kann mir jemand erklären wieso?</p>
<p>Vielen Dank im voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/172085/pointer-löschen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 16:11:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/172085.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 01 Feb 2007 11:10:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Pointer löschen on Thu, 01 Feb 2007 11:10:49 GMT]]></title><description><![CDATA[<p>Hallo zusammen</p>
<p>habe folgendes geschrieben:</p>
<pre><code>time_t currentTime;
    struct tm * timeinfo;

    currentTime = time(NULL);
    timeinfo    = localtime(&amp;currentTime);

    o_currentTime.r_date.i_year         = timeinfo-&gt;tm_year + 1900;
    o_currentTime.r_date.i_month        = timeinfo-&gt;tm_mon  + 1;
    o_currentTime.r_date.i_day          = timeinfo-&gt;tm_mday;

    o_currentTime.r_time.i_hour         = timeinfo-&gt;tm_hour;
    o_currentTime.r_time.i_minute       = timeinfo-&gt;tm_min;
    o_currentTime.r_time.i_seconds      = timeinfo-&gt;tm_sec;
    o_currentTime.r_time.i_milliseconds = 0;

    delete timeinfo;
</code></pre>
<p>Normaerweise muss man doch am ende einer Methode mit den überschüssigen Pointer aufräumen, glaube ich idenenfalls.</p>
<p>Nun habe ich aber ein Problem mit dieser Methode, läuft sie das erste Mal durch hat das System kein Problem, sobald das delete aber zum zweiten mal aufgerufen wird bricht das Prog ab mit folgener Meldung:<br />
&lt;&lt;User breakpoint called from code at 0x77f75a58&gt;&gt;</p>
<p>Kann mir jemand erklären wieso?</p>
<p>Vielen Dank im voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1221009</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1221009</guid><dc:creator><![CDATA[flownfluid]]></dc:creator><pubDate>Thu, 01 Feb 2007 11:10:49 GMT</pubDate></item><item><title><![CDATA[Reply to Pointer löschen on Thu, 01 Feb 2007 11:25:18 GMT]]></title><description><![CDATA[<p>umgeht das problem doch einfach indem du anstatt n pointer eine instantz verwendest - wenn es in eine funktion ausgelagert ist wird es danach eh immer wieder zerstoert</p>
<p>ein performance gewinn des pointers kann ich mir auch nicht vorstellen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1221020</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1221020</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Thu, 01 Feb 2007 11:25:18 GMT</pubDate></item><item><title><![CDATA[Reply to Pointer löschen on Thu, 01 Feb 2007 11:29:46 GMT]]></title><description><![CDATA[<p>Hallo,<br />
localtime liefert einen Zeiger auf ein statisches tm-Objekt. Der delete-Aufruf ist schlicht falsch. Und zwar bereits der erste. Der Vorteil der Verwendung eines statischen Elements liegt u.A. darin, dass du eben kein Speichermanagement durchführen musst. Einer der Nachteile ist, dass nachfolgende Aufrufe die Ergebnisse vorheriger Aufrufe verändern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1221022</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1221022</guid><dc:creator><![CDATA[HumeSikkins]]></dc:creator><pubDate>Thu, 01 Feb 2007 11:29:46 GMT</pubDate></item><item><title><![CDATA[Reply to Pointer löschen on Thu, 01 Feb 2007 11:40:52 GMT]]></title><description><![CDATA[<p>flownfluid schrieb:</p>
<blockquote>
<p>...Normaerweise muss man doch am ende einer Methode mit den überschüssigen Pointer aufräumen, glaube ich idenenfalls....</p>
</blockquote>
<p>Das stimmt halt so nicht (ganz).<br />
Du musst überschüssigen <strong>Speicher</strong> aufräumen.<br />
Eigentlich einfach zu merken: Wenn Du irgendwo &quot;new&quot; (oder &quot;malloc&quot;) schreibst, musst Du auch &quot;delete&quot; (free) schreiben.</p>
<p>Hier schreibst Du kein new/malloc ... wenn dann auch nicht die Dokumentation der genutzten Funktion ein delete/free fordert, brauchst Du's auch nicht zu tun (bzw. ist sogar falsch - wie hier). <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1221027</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1221027</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Thu, 01 Feb 2007 11:40:52 GMT</pubDate></item><item><title><![CDATA[Reply to Pointer löschen on Thu, 01 Feb 2007 11:44:07 GMT]]></title><description><![CDATA[<p>Mr Evil schrieb:</p>
<blockquote>
<p>umgeht das problem doch einfach indem du anstatt n pointer eine instantz verwendest...</p>
</blockquote>
<p>Das ist an und für sich ein guter Tipp ... geht in diesem konkreten Fall aber halt nicht. <code>localtime()</code> liefert einfach einen Zeiger (auf ein statisches Objekt) zurück ... da hat man keine Wahl. (Dass das kein gutes Design ist, habe alle schon längst festgestellt - ist aber nicht mehr zu ändern).</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1221030</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1221030</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Thu, 01 Feb 2007 11:44:07 GMT</pubDate></item></channel></rss>