• <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 陳志遠 閱讀(514) | 評論 (0)編輯 收藏

            2013年12月17日

            轉載網址: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 陳志遠 閱讀(325) | 評論 (0)編輯 收藏

            2013年12月16日

                 摘要: 網上看到的,非常有用,轉載一下, 非常感謝作者。  閱讀全文
            posted @ 2013-12-16 00:01 陳志遠 閱讀(6151) | 評論 (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     //繼承函數
             25  25 public:
             26  26     //加入處理序列
             27  27     virtual bool  push(autoItem *p);
             28  28     //執行處理序列
             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 陳志遠 閱讀(1457) | 評論 (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)   ->轉置()                            ()                                    DX: 左手坐標系,行向量           OpenGL:  右手坐標系,列向量 
            posted @ 2013-04-16 11:34 陳志遠 閱讀(358) | 評論 (0)編輯 收藏

            2013年3月24日

                 摘要: SQLite存取二進制數據(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 陳志遠 閱讀(9779) | 評論 (1)編輯 收藏

            2012年7月27日

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


             
            按下面的方法使用調試堆函數
            在XXXView.cpp中添加下面粗體行

            你再看看輸出結果,是不是有很多的內存泄漏?

            #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)

                   首先,應該是MFC報告我們發現內存泄漏。注意:要多運行幾次,以確定輸出的內容不變,特別是{}之間的數值,不能變,否則下面的方法就不好用了。
            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行,發生了內存泄漏。你雙擊改行就可以轉到該文件的54行了。但是有時候這一信息并不能用來準確判斷,比如:MFC可能報告Strcore.cpp文件的某行,實際上這是CString的實現函數,此時并不知道什么時候發生了內存泄漏。

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

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


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

                     有了這些信息,我們可以開始調試內存泄漏了。

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

            image002.jpg

                     在Watch窗口中輸入:

            {,,msvcrtd.dll}_crtBreakAlloc


              image003.jpg

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

            image004.jpg

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

            image005.jpg

                     然后我們打開堆棧窗口:

            image006.jpgimage007.jpg

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

            image008.jpg

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




             

            你也許還沒用過的vc++的調試的功能

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

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

            How to use _crtBreakAlloc to debug a memory allocation你可以找到英文的更完整的版本,靜態鏈接和動態連接到C運行庫的名稱是不一樣的
            靜態:_crtBreakAlloc
            動態:{,,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
            這個是我轉的時候的地址:http://blog.sina.com.cn/s/blog_630d564a0100gq5k.html

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

            2012年7月17日

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

            http://blog.vckbase.com/smileonce/articles/1184.html
            (這個鏈接->關于Debug和Release之本質區別

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

                1 ASSERT與VERIFY宏在Debug模式下作用基本一致,二者都對表達式的值進行計算,如果值為非0,則什么事也不做;如果值為0,則輸出診斷信息。
                2 ASSERT與VERIFY宏在Release模式下效果完全不一樣。ASSERT不計算表達式的值,也不會輸出診斷信息;VERIFY計算表達式的值,但不管值為0還是非0都不會輸出診斷信息。
            VERIFY   與ASSERT用在程序調試上并無本質上的區別。  
              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() 。事實上,這些宏都是調用了 assert() 函數,只不過附加了一些與庫有關的調試代碼。如果你在這些宏中加入了任何程序代碼,而不只是布爾表達式(例如賦值、能改變變量值的函數調用 等),那么 Release 版都不會執行這些操作,從而造成錯誤。初學者很容易犯這類錯誤,查找的方法也很簡單,因為這些宏都已在上面列出,只要利用 VC++ 的 Find in Files 功能在工程所有文件中找到用這些宏的地方再一一檢查即可。另外,有些高手可能還會加入 #ifdef _DEBUG 之類的條件編譯,也要注意一下。
             順便值得一提的是 VERIFY() 宏,這個宏允許你將程序代碼放在布爾表達式里。這個宏通常用來檢查 Windows API 的返回值。有些人可能為這個原因而濫用 VERIFY() ,事實上這是危險的,因為 VERIFY() 違反了斷言的思想,不能使程序代碼和調試代碼完全分離,最終可能會帶來很多麻煩。因此,專家們建議盡量少用這個宏
            posted @ 2012-07-17 23:38 陳志遠 閱讀(470) | 評論 (0)編輯 收藏
            僅列出標題  

            導航

            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            統計

            常用鏈接

            留言簿

            隨筆檔案

            文章分類

            Othor's blog

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            精品久久久久久中文字幕大豆网 | 99久久99久久| 久久国产精品无码HDAV| 久久九九全国免费| 日韩欧美亚洲综合久久| 久久永久免费人妻精品下载| 日本精品久久久久中文字幕8| 欧美亚洲另类久久综合婷婷| 久久精品a亚洲国产v高清不卡| 久久美女人爽女人爽| 久久精品一区二区三区AV| 成人久久综合网| 狠狠精品久久久无码中文字幕| 国内精品久久国产大陆| 欧美日韩久久中文字幕| 美女写真久久影院| 久久久久久亚洲AV无码专区| 久久亚洲精品无码播放| 国产精品免费福利久久| 18禁黄久久久AAA片| 国产精品免费久久久久久久久 | 三级三级久久三级久久| 国产午夜精品久久久久九九电影| 色综合久久无码中文字幕| 久久精品国产福利国产琪琪| 久久精品成人免费看| 日本欧美久久久久免费播放网| 亚洲v国产v天堂a无码久久| 久久国产成人亚洲精品影院| 91久久精品国产免费直播| 97久久国产亚洲精品超碰热| 久久夜色精品国产噜噜噜亚洲AV| 久久精品国产2020| 色综合久久综合中文综合网| 午夜精品久久久久久99热| 久久香蕉超碰97国产精品| 国内精品九九久久久精品| 久久大香香蕉国产| 久久香蕉国产线看观看乱码| 久久99热国产这有精品| 日本精品久久久中文字幕|