• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            隨心動

            2014年3月13日

                 摘要:   閱讀全文
            posted @ 2014-03-13 03:06 陳志遠 閱讀(519) | 評論 (0)編輯 收藏

            2013年12月17日

            轉(zhuǎn)載網(wǎng)址:http://blog.csdn.net/windboyzsj/article/details/2790485
             1 #include <iostream.h> 
             2 class Singleton 
             3 { 
             4 public
             5 ~Singleton(){cout<<"singleton deconstruct"<<endl;} 
             6 static Singleton* Instance() 
             7 { 
             8   if (_instance == NULL) 
             9   { 
            10    _instance = new Singleton(); 
            11    static Cleaner cl; //延遲到這里 
            12   } 
            13   return _instance; 
            14 } 
            15 void Print(char* str) 
            16 { 
            17   cout<<"singleton print:"<<str<<endl; 
            18 } 
            19 private
            20 Singleton(){cout<<"singleton construct"<<endl;} 
            21 static Singleton* _instance; 
            22 class Cleaner 
            23 { 
            24 public
            25   Cleaner(){cout<<"cleaner construct"<<endl;} 
            26   ~Cleaner() 
            27   { 
            28    cout<<"cleaner deconstruct"<<endl; 
            29    if(Singleton::Instance()) 
            30    delete Singleton::Instance(); 
            31   } 
            32 }; 
            33 }; 
            34 Singleton* Singleton::_instance = NULL; 
            35 int main(int argc, char* argv[]) 
            36 { 
            37 Singleton::Instance()->Print("print 1"); 
            38 Singleton::Instance()->Print("print 2"); 
            39 return 0; 
            40 }
            posted @ 2013-12-17 04:18 陳志遠 閱讀(328) | 評論 (0)編輯 收藏

            2013年12月16日

                 摘要: 網(wǎng)上看到的,非常有用,轉(zhuǎn)載一下, 非常感謝作者。  閱讀全文
            posted @ 2013-12-16 00:01 陳志遠 閱讀(6164) | 評論 (0)編輯 收藏

            2013年12月15日

            一個自處理的list 用途多多
              1
               1 //子項
              2   2 class autoItem
              3   3 {
              4   4 public:
              5   5     //處理
              6   6     virtual bool  proces() = 0;
              7   7     //彈出
              8   8     virtual bool  ok() = 0; 
              9   9     //處理順序
             10  10     virtual int   Order(){return 0;}
             11  11 };
             12  12 enum sortType
             13  13 {
             14  14     ST_Input,
             15  15     ST_Custom
             16  16 };
             17  17 //自處理list
             18  18 class _autolist
             19  19 {
             20  20 public:
             21  21     _autolist( sortType _type );
             22  22     ~_autolist();
             23  23 
             24  24     //繼承函數(shù)
             25  25 public:
             26  26     //加入處理序列
             27  27     virtual bool  push(autoItem *p);
             28  28     //執(zhí)行處理序列
             29  29     virtual bool  go();
             30  30     //清理所有
             31  31     virtual bool  clear(); 
             32  32 
             33  33     //
             34  34 protected:
             35  35     std::list<autoItem*> itemList;
             36  36     sortType _sortType;
             37  37 };
             38  38 
             39  39 
             40  40 _autolist::_autolist( sortType _type )
             41  41 {
             42  42     _sortType = _type;
             43  43 }
             44  44 
             45  45 _autolist::~_autolist()
             46  46 {
             47  47     clear();
             48  48 }
             49  49 
             50  50 bool _autolist::push( autoItem *p )
             51  51 {
             52  53     if (p == NULL) return false;
             53  54     switch (_sortType)
             54  55     {
             55  56     case ST_Input:
             56  57         {
             57  58             itemList.insert(itemList.end(),p);
             58  59             return true;
             59  60         }
             60  61     case ST_Custom:
             61  62         {
             62  63             if (itemList.size() == 0)
             63  64             {
             64  65                 itemList.push_back(p);
             65  66                 return true;
             66  67             }
             67  68             static std::list<autoItem*>::iterator it;
             68  69             it= itemList.begin();
             69  70             for (; it != itemList.end();it++)
             70  71             {
             71  72                 if ((*it)->Order() < p->Order())continue;
             72  73                 itemList.insert(it,p);
             73  74                 break;
             74  75             }
             75  76             return true;
             76  77         }
             77  78     default:
             78  80         return false;
             79  82     }
             80  83     return false;
             81  84 }
             82  85 
             83  86 bool _autolist::go()
             84  87 {
             85  88     static std::list<autoItem*>::iterator it;
             86  89     int nsize = itemList.size();
             87  90     it= itemList.begin();
             88  91     for (; it != itemList.end();)
             89  92     {
             90  93         (*it)->proces();
             91  94         if ( (*it)->ok())
             92  95             it = itemList.erase(it);
             93  96         else
             94  97             it++;
             95  98     }
             96  99     return true;
             97 100 }
             98 101 
             99 102 bool _autolist::clear()
            100 103 {
            101 104     itemList.clear();
            102 105     return true;
            103 106 }
            104 107 
            105 
            posted @ 2013-12-15 22:30 陳志遠 閱讀(1465) | 評論 (2)編輯 收藏

            2013年4月16日

            點:
               v1(x,y,z)           ->v1(x,y,-z)                      Z軸方向不同                       DX:  z正方向屏幕向里           OpengGL:  z正方向屏幕向外
            面:
               face1(v1,v2,v3) -> face(v1,v3,v2)                正面相反                           DX:  面正方向是順時針           OpengGL:  面正方向逆時針
            紋理坐標
               tz(u,v)              -> tz(u,1.0f-z)                   (0,0)點不同                       DX:  (0,0)左上角                   OpengGL:  (0,0)左下角
            矩陣:
               m(m00,...m33)   ->轉(zhuǎn)置()                            ()                                    DX: 左手坐標系,行向量           OpenGL:  右手坐標系,列向量 
            posted @ 2013-04-16 11:34 陳志遠 閱讀(366) | 評論 (0)編輯 收藏

            2013年3月24日

                 摘要: SQLite存取二進制數(shù)據(jù)(http://hi.baidu.com/ejoywx/blog/item/4d7b418c8677cc00b31bbae9.html)http://blog.sina.com.cn/s/blog_60f8483a0100ydaw.html Code highlighting produced by Actipro CodeHighlighter (freeware)h...  閱讀全文
            posted @ 2013-03-24 16:06 陳志遠 閱讀(9799) | 評論 (1)編輯 收藏

            2012年7月27日

            VC++ IDE 的默認狀態(tài)(VC6)是沒有啟用內(nèi)存泄漏檢測機制的,也就是說即使某段代碼有內(nèi)存泄漏,調(diào)試會話的 Output 窗口的 Debug 頁不會輸出有關(guān)內(nèi)存泄漏信息。你必須設(shè)定以啟用內(nèi)存泄漏檢測機制。


             
            按下面的方法使用調(diào)試堆函數(shù)
            在XXXView.cpp中添加下面粗體行

            你再看看輸出結(jié)果,是不是有很多的內(nèi)存泄漏?

            #define _CRTDBG_MAP_ALLOC
            #include<stdlib.h>
            #include<crtdbg.h>


            CXXXView::~CXXXView()
            {
                 _CrtDumpMemoryLeaks();
            }

            文章出處:DIY部落(http://www.diybl.com/course/3_program/c++/cppjs/2007925/73624.html)

                   首先,應(yīng)該是MFC報告我們發(fā)現(xiàn)內(nèi)存泄漏。注意:要多運行幾次,以確定輸出的內(nèi)容不變,特別是{}之間的數(shù)值,不能變,否則下面的方法就不好用了。
            image001.jpg

                    我們來看看:

            F:\CodeSample\Test\TestPipe\LeakTest\MainFrm.cpp( 54 { 86 normal block at  0x00422E80 10  bytes  long .
             Data: 
            <            >  1F 1F 1F 1F 1F CD CD CD CD CD 


                     F:\CodeSample\Test\TestPipe\LeakTest\MainFrm.cpp(54) 告訴我們MFC認為是在該文件的54行,發(fā)生了內(nèi)存泄漏。你雙擊改行就可以轉(zhuǎn)到該文件的54行了。但是有時候這一信息并不能用來準確判斷,比如:MFC可能報告Strcore.cpp文件的某行,實際上這是CString的實現(xiàn)函數(shù),此時并不知道什么時候發(fā)生了內(nèi)存泄漏。

                     此時我們需要更多的信息。那么我們看看緊接其后的:

            { 86 normal block at  0x00422E80 10  bytes  long .
             Data: 
            <            >  1F 1F 1F 1F 1F CD CD CD CD CD 


                     它告訴我們:在第86次分配的內(nèi)存沒有釋放,一共有10字節(jié),內(nèi)容移16進制方式打印給我們看。

                     有了這些信息,我們可以開始調(diào)試內(nèi)存泄漏了。

                     按下F10在程序的剛開始處,停下來,打開Watch窗口:

            image002.jpg

                     在Watch窗口中輸入:

            {,,msvcrtd.dll}_crtBreakAlloc


              image003.jpg

                     然后更改值為上文提到的分配次數(shù):86

            image004.jpg

                     接著按下F5繼續(xù),然后在第86次分配的時候會發(fā)生中斷:

            image005.jpg

                     然后我們打開堆棧窗口:

            image006.jpgimage007.jpg

                  往回查看最近我們自己的代碼,雙擊堆棧我們自己的函數(shù)那一層,上圖有綠色三角的那一層。就定位到泄漏時分配的內(nèi)存了。

            image008.jpg

                     之后,就是看你的編碼功底了。




             

            你也許還沒用過的vc++的調(diào)試的功能

            From: http://www.cnitblog.com/Raistlin/archive/2005/12/14/5380.html

            剛剛在IT博客網(wǎng)閑逛的時候看到了孤獨的夜的一片文章《如何調(diào)試MFC中的內(nèi)存泄漏》,講道用設(shè)置{,,msvcrtd.dll}_crtBreakAlloc這個變量來調(diào)試內(nèi)存泄露的問題。

            How to use _crtBreakAlloc to debug a memory allocation你可以找到英文的更完整的版本,靜態(tài)鏈接和動態(tài)連接到C運行庫的名稱是不一樣的
            靜態(tài):_crtBreakAlloc
            動態(tài):{,,msvcr40d.dll}*__p__crtBreakAlloc()  (vc++4.0 和4.1版本,估計沒人在用吧)
                     {,,msvcrtd.dll}*__p__crtBreakAlloc()  (Visual C++ 4.2 or later)
                     {,,msvcrtd.dll}_crtBreakAlloc (好像這樣也是可以的)


            {,,msvcrtd.dll}__p__crtBreakAlloc()是個什么東西呢?

            查看msdn索引“Advanced Breakpoint”and you will find out...

            語法如下:
            {[function],[source],[exe] } location
            {[function],[source],[exe] } variable_name
            {[function],[source],[exe] } expression_r_r
            這個是我轉(zhuǎn)的時候的地址:http://blog.sina.com.cn/s/blog_630d564a0100gq5k.html

            posted @ 2012-07-27 19:20 陳志遠 閱讀(454) | 評論 (0)編輯 收藏

            2012年7月17日

            原文地址:http://blog.csdn.net/liuchanghe/article/details/1425080

            http://blog.vckbase.com/smileonce/articles/1184.html
            (這個鏈接->關(guān)于Debug和Release之本質(zhì)區(qū)別

            今天公司有同事問我ASSERT與VERIFY宏有什么區(qū)別,雖然平時常用這兩個宏對一些變量在Debug模式下作判斷,但一時還真答不上來二者之間的具體差別,看來只是知其然不知其所以然。后來查了一些資料,總算弄清楚了二者之間的區(qū)別,整理后與同事交流了一番,感覺收獲還是蠻大的。下面對我的理解進行了總結(jié):

                1 ASSERT與VERIFY宏在Debug模式下作用基本一致,二者都對表達式的值進行計算,如果值為非0,則什么事也不做;如果值為0,則輸出診斷信息。
                2 ASSERT與VERIFY宏在Release模式下效果完全不一樣。ASSERT不計算表達式的值,也不會輸出診斷信息;VERIFY計算表達式的值,但不管值為0還是非0都不會輸出診斷信息。
            VERIFY   與ASSERT用在程序調(diào)試上并無本質(zhì)上的區(qū)別。  
              In   the   debug   version   of   MFC,   the   VERIFY   macro   evaluates   its   argument.   If   the   result   is   0,    
              the   macro   prints   a   diagnostic   message   and   halts   the   program.   If   the   condition   is   nonzero,    
              it   does   nothing.  
               
              In   the   release   version   of   MFC,   VERIFY   evaluates   the   expression   but   does   not   print   or   interrupt   the   program.   For   example,   if   the   expression   is   a   function   call,   the   call   will   be   made.  
            斷言類型  定義
            ANSI C 斷言 void assert(int expression );
            C Runtime Lib 斷言 _ASSERT( booleanExpression );
            _ASSERTE( booleanExpression );
            MFC 斷言 ASSERT( booleanExpression );
            VERIFY( booleanExpression );
            ASSERT_VALID( pObject );
            ASSERT_KINDOF( classname, pobject );
            ATL 斷言 ATLASSERT( booleanExpression );
             此外,TRACE() 宏的編譯也受 _DEBUG 控制。
             所有這些斷言都只在 Debug版中才被編譯,而在 Release 版中被忽略。唯一的例外是 VERIFY() 。事實上,這些宏都是調(diào)用了 assert() 函數(shù),只不過附加了一些與庫有關(guān)的調(diào)試代碼。如果你在這些宏中加入了任何程序代碼,而不只是布爾表達式(例如賦值、能改變變量值的函數(shù)調(diào)用 等),那么 Release 版都不會執(zhí)行這些操作,從而造成錯誤。初學(xué)者很容易犯這類錯誤,查找的方法也很簡單,因為這些宏都已在上面列出,只要利用 VC++ 的 Find in Files 功能在工程所有文件中找到用這些宏的地方再一一檢查即可。另外,有些高手可能還會加入 #ifdef _DEBUG 之類的條件編譯,也要注意一下。
             順便值得一提的是 VERIFY() 宏,這個宏允許你將程序代碼放在布爾表達式里。這個宏通常用來檢查 Windows API 的返回值。有些人可能為這個原因而濫用 VERIFY() ,事實上這是危險的,因為 VERIFY() 違反了斷言的思想,不能使程序代碼和調(diào)試代碼完全分離,最終可能會帶來很多麻煩。因此,專家們建議盡量少用這個宏
            posted @ 2012-07-17 23:38 陳志遠 閱讀(479) | 評論 (0)編輯 收藏
            僅列出標題  

            導(dǎo)航

            <2013年12月>
            24252627282930
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            統(tǒng)計

            常用鏈接

            留言簿

            隨筆檔案

            文章分類

            Othor's blog

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            国内精品久久久久久久久电影网 | 久久无码中文字幕东京热| 久久高清一级毛片| 偷窥少妇久久久久久久久| 久久精品无码专区免费青青| 美女写真久久影院| 狠狠色丁香婷婷久久综合五月| 新狼窝色AV性久久久久久| 成人精品一区二区久久| 久久婷婷五月综合色奶水99啪| 91久久精一区二区三区大全| 青青草国产97免久久费观看| 久久精品九九亚洲精品| 久久精品一区二区影院| 精品无码久久久久国产| 亚洲第一永久AV网站久久精品男人的天堂AV | 久久综合给合久久狠狠狠97色69| 国产午夜精品理论片久久 | 亚洲欧美国产精品专区久久| 99久久超碰中文字幕伊人| 久久综合偷偷噜噜噜色| 久久se精品一区精品二区国产| 久久香蕉超碰97国产精品| 久久受www免费人成_看片中文| 国产成人精品久久亚洲高清不卡| 久久综合香蕉国产蜜臀AV| 久久亚洲精品国产精品婷婷 | 久久精品国产影库免费看| 久久久午夜精品| 久久国产成人| 久久99精品久久久久久不卡| 久久99国产精品久久99果冻传媒| 亚洲日韩中文无码久久| 国产精品久久新婚兰兰| 伊人久久五月天| 精品国产日韩久久亚洲| 精品久久久久久久国产潘金莲| 日韩欧美亚洲综合久久影院Ds | 久久久久亚洲精品无码蜜桃| 亚洲AV无码一区东京热久久| 人妻无码久久一区二区三区免费 |