Welcome to Windows Presentation Foundation (WPF)
Top Tasks :

WPF Team Bloggers

Browse by Tags

All Tags » C++   (RSS)

  • Source code for Windows Graphics Programming: Win32 GDI and DirectDraw

    Source code for Windows Graphics Programming: Win32 GDI and DirectDraw used to be on http://safariexamples.informit.com/0130869856/ . But link has been broken for quite sometimes. I've received a few emails from readers who has lost the CD of the book. If you need the source code, here is it: www.fengyuan.com/sample/Samples.zip Read More...
  • Anatomy of STL Vector: Data Size

    In the last post, we discussed the cost of using STL vector to module size. Now let’s take a look at how STL vector manages its data. Dia2Dump (Source code available in Microsoft Visual Studio 8\Dia SDK\Samples\Dia2Dump directory) shows the following internal structure of vector<short:> UDT : std::vector<short,std::allocator<short> > BaseClass : std::_Vector_val<short,std::allocator<short> >, offset = 0x0 BaseClass : std::_Container_base, offset = 0x0 Data : this+0x0, Member, Type: class std::allocator<short>, _Alval Data : this+0x4, Member, Type: short *, _Myfirst Data : this+0x8, Member, Type: short *, _Mylast Data : this+0xc, Member, Type: short *, _Myend Class vector<short> derives from _Vector_val<short>, which in turn derives from _Container_base. _Vector_val has one member variable, _Alval, which is of the type allocator<short>. Also allocator<short> does not have any member variable; its still occupies 1-byte space. Due Read More...
  • Anatomy of STL vector: Module Size

    If you need a dynamic array in C++, a widely used class is the vector template class in STL. There are even books recommending replacement of plain C++ array with STL vector. This series is going to look at how STL vector is implemented and what is the cost associated with using STL vector. Let’s start with an empty console program: #include <stdio.h> #include <tchar.h> int _tmain( int argc, _TCHAR* argv[]) { int sum = 1; return sum; } When compiled in release mode (full optimization, favor small code, multi-threaded runtime), it generates an EXE with 49,152 bytes. Here is a break down of various sections in the EXE. Code .text section 24,920 bytes Read-only data .rdata section 6,892 bytes Read-write data .data section 6,524 bytes Resource .rsrc section 176 bytes If we add a vector of integer, the code becomes: #include <stdio.h> #include <tchar.h> #include <vector> int _tmain( int argc, _TCHAR* argv[]) { int sum = 1; std::vector< int > intvector; intvector.push_back(3); Read More...

Copyright © 2006 Microsoft Corporation. All Rights Reserved. | Terms of Use | Privacy Statement | Contact Us