<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-459458859817042968</atom:id><lastBuildDate>Sat, 02 May 2009 21:08:39 +0000</lastBuildDate><title>Artak's Tech Blog</title><description></description><link>http://www.kalantarian.org/artak/techblog/</link><managingEditor>noreply@blogger.com (Artak)</managingEditor><generator>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-459458859817042968.post-5637294891910076735</guid><pubDate>Sat, 02 May 2009 20:21:00 +0000</pubDate><atom:updated>2009-05-02T14:08:39.789-07:00</atom:updated><title>Hold'em Simulator</title><description>We just released Burly Marmot Software Hold'em Simulator.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://holdem-odds.com/"&gt;http://holdem-odds.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The easy to use program estimates hand odds and provides all sorts of statistics.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='http://res1.blogblog.com/tracker/459458859817042968-5637294891910076735?l=www.kalantarian.org%2Fartak%2Ftechblog'/&gt;&lt;/div&gt;</description><link>http://www.kalantarian.org/artak/techblog/2009/05/holdem-simulator.html</link><author>noreply@blogger.com (Artak)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-459458859817042968.post-1583915429737172815</guid><pubDate>Fri, 12 Sep 2008 03:41:00 +0000</pubDate><atom:updated>2008-09-11T20:48:38.120-07:00</atom:updated><title>Events versus delegates in C#</title><description>Finally somebody clearly defined the difference between C# events and multicast delegates.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.monstuff.com/archives/000040.html"&gt;http://blog.monstuff.com/archives/000040.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Conclusion&lt;/em&gt;&lt;br /&gt;We have seen that the event keyword is a modifier for a delegate declaration that allows it to be included in an interface, constraints it invocation from within the class that declares it, provides it with a pair of customizable accessors (add and remove) and forces the signature of the delegate (when used within the .NET framework).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='http://res1.blogblog.com/tracker/459458859817042968-1583915429737172815?l=www.kalantarian.org%2Fartak%2Ftechblog'/&gt;&lt;/div&gt;</description><link>http://www.kalantarian.org/artak/techblog/2008/09/events-versus-delegates-in-c.html</link><author>noreply@blogger.com (Artak)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-459458859817042968.post-6763196902992805358</guid><pubDate>Tue, 01 Jul 2008 20:56:00 +0000</pubDate><atom:updated>2008-07-02T22:42:44.207-07:00</atom:updated><title>"delete []" versus just "delete" in C++</title><description>This week I was asked for the second time to "fix" a bug in my code and use "delete []" on arrays instead of "delete". I did an informal survey and all of the people I asked told me using plain "delete" on arrays is wrong.&lt;br /&gt;&lt;br /&gt;As I remembered that it is ok, I decided to do some experiments.&lt;br /&gt;&lt;br /&gt;I wrote this code and compiled it in VS2008:&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:small"&gt;&lt;br /&gt;#include "stdafx.h"&lt;br /&gt;TCHAR * buf = NULL;&lt;br /&gt;int * intbuf = NULL;&lt;br /&gt;&lt;br /&gt;class Foo&lt;br /&gt;{&lt;br /&gt;   public:&lt;br /&gt;   int x;&lt;br /&gt;   // ~Foo() { x = 2; }&lt;br /&gt;};&lt;br /&gt;Foo * fooBuf = NULL;&lt;br /&gt;&lt;br /&gt;int _tmain(int argc, _TCHAR* argv[])&lt;br /&gt;{&lt;br /&gt;   delete buf;&lt;br /&gt;   delete [] buf;&lt;br /&gt;   delete intbuf;&lt;br /&gt;   delete [] intbuf;&lt;br /&gt;   delete fooBuf;&lt;br /&gt;   delete [] fooBuf;&lt;br /&gt;   return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now let us check the disassembly:&lt;br /&gt;&lt;pre style="font-size:small"&gt;&lt;br /&gt;         delete buf;&lt;br /&gt;003E1000 mov eax,dword ptr [buf (3E3370h)]&lt;br /&gt;003E1005 push eax&lt;br /&gt;003E1006 call operator delete (3E105Ch)&lt;br /&gt;         delete [] buf;&lt;br /&gt;003E100B mov eax,dword ptr [buf (3E3370h)]&lt;br /&gt;003E1011 push eax&lt;br /&gt;003E1012 call operator delete (3E105Ch)&lt;br /&gt;&lt;br /&gt;         delete intbuf;&lt;br /&gt;003E1017 mov eax,dword ptr [intbuf (3E3374h)]&lt;br /&gt;003E101D push eax&lt;br /&gt;003E101E call operator delete (3E105Ch)&lt;br /&gt;         delete [] intbuf;&lt;br /&gt;003E1023 mov eax,dword ptr [intbuf (3E3374h)]&lt;br /&gt;003E1028 push eax&lt;br /&gt;003E1029 call operator delete (3E105Ch)&lt;br /&gt;&lt;br /&gt;         delete fooBuf;&lt;br /&gt;003E102E mov eax,dword ptr [fooBuf (3E3378h)]&lt;br /&gt;003E1034 push eax&lt;br /&gt;003E1035 call operator delete (3E105Ch)&lt;br /&gt;         delete [] fooBuf;&lt;br /&gt;003E103A mov eax,dword ptr [fooBuf (3E3378h)]&lt;br /&gt;003E1040 push eax&lt;br /&gt;003E1041 call operator delete (3E105Ch)&lt;br /&gt;&lt;br /&gt;003E1046 add esp,18h&lt;br /&gt;&lt;br /&gt;         return 0;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;All identical.&lt;br /&gt;&lt;br /&gt;Now if you uncomment the destructor interesting things start to happen on the last two deletes:&lt;br /&gt;&lt;pre style="font-size:small"&gt;&lt;br /&gt;         delete fooBuf;&lt;br /&gt;002C103E mov eax,dword ptr [fooBuf (2C3378h)]&lt;br /&gt;002C1043 add esp,10h&lt;br /&gt;002C1046 test eax,eax&lt;br /&gt;002C1048 je wmain+71h (2C1081h)&lt;br /&gt;002C104A push eax&lt;br /&gt;002C104B mov dword ptr [eax],2&lt;br /&gt;002C1051 call operator delete (2C1094h)&lt;br /&gt;002C1056 mov eax,dword ptr [fooBuf (2C3378h)]&lt;br /&gt;002C105B add esp,4&lt;br /&gt;&lt;br /&gt;         delete [] fooBuf;&lt;br /&gt;002C105E test eax,eax&lt;br /&gt;002C1060 je wmain+71h (2C1081h)&lt;br /&gt;002C1062 mov ecx,dword ptr [eax-4]&lt;br /&gt;002C1065 push esi&lt;br /&gt;002C1066 lea esi,[eax-4]&lt;br /&gt;002C1069 push offset Foo::~Foo (2C1000h)&lt;br /&gt;002C106E push ecx&lt;br /&gt;002C106F push 4&lt;br /&gt;002C1071 push eax&lt;br /&gt;002C1072 call `eh vector destructor iterator' (2C10F8h)&lt;br /&gt;002C1077 push esi&lt;br /&gt;002C1078 call operator delete (2C1094h)&lt;br /&gt;002C107D add esp,4&lt;br /&gt;002C1080 pop esi&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The calls are very different because in second case it goes through the array and destructs individual elements, while in the first just deletes the memory.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br /&gt;“delete” and “delete []” are equivalent unless the array contains objects and that objects have a destructor.&lt;br /&gt;&lt;br /&gt;This said it is still probably good idea to use "delete []" for the clarity alone.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='http://res1.blogblog.com/tracker/459458859817042968-6763196902992805358?l=www.kalantarian.org%2Fartak%2Ftechblog'/&gt;&lt;/div&gt;</description><link>http://www.kalantarian.org/artak/techblog/2008/07/delete-versus-just-delete.html</link><author>noreply@blogger.com (Artak)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-459458859817042968.post-6169457960795566948</guid><pubDate>Tue, 10 Jun 2008 23:07:00 +0000</pubDate><atom:updated>2008-06-10T16:13:05.869-07:00</atom:updated><title>.NET Zero</title><description>I second &lt;a href="http://blogs.msdn.com/digitalnetbizz/archive/2007/01/27/net-book-zero.aspx"&gt;digitalnetbizz.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The most amazing book about .NET is free and is available at &lt;a href="http://www.charlespetzold.com/dotnet/index.html"&gt; Charles Petzold's web site. &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In general check out everything written by Charles. He is a category of his own among technology writers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='http://res1.blogblog.com/tracker/459458859817042968-6169457960795566948?l=www.kalantarian.org%2Fartak%2Ftechblog'/&gt;&lt;/div&gt;</description><link>http://www.kalantarian.org/artak/techblog/2008/06/net-zero.html</link><author>noreply@blogger.com (Artak)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-459458859817042968.post-7066049142858062887</guid><pubDate>Wed, 04 Jun 2008 01:40:00 +0000</pubDate><atom:updated>2008-07-02T22:26:54.970-07:00</atom:updated><title>Breaking the Myth of Megapixels</title><description>You would think, that by now the computer magazines would manage to get it right.&lt;br /&gt;&lt;br /&gt;Well, &lt;a href="http://www.nytimes.com/2007/02/08/technology/08pogue.html?_r=2&amp;amp;ref=technology&amp;amp;oref=slogin&amp;amp;oref=slogin"&gt;at least someone who writes for NY times does. &lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='http://res1.blogblog.com/tracker/459458859817042968-7066049142858062887?l=www.kalantarian.org%2Fartak%2Ftechblog'/&gt;&lt;/div&gt;</description><link>http://www.kalantarian.org/artak/techblog/2008/06/breaking-myth-of-megapixels.html</link><author>noreply@blogger.com (Artak)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-459458859817042968.post-4765986808217488561</guid><pubDate>Tue, 03 Jun 2008 18:58:00 +0000</pubDate><atom:updated>2008-06-03T11:59:59.909-07:00</atom:updated><title>Don't Let Architecture Astronauts Scare You</title><description>Check what Joel says about &lt;a href="http://www.joelonsoftware.com/articles/fog0000000018.html"&gt;Architecture Astronauts&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='http://res1.blogblog.com/tracker/459458859817042968-4765986808217488561?l=www.kalantarian.org%2Fartak%2Ftechblog'/&gt;&lt;/div&gt;</description><link>http://www.kalantarian.org/artak/techblog/2008/06/dont-let-architecture-astronauts-scare.html</link><author>noreply@blogger.com (Artak)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item></channel></rss>
