ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

eh.cc
Go to the documentation of this file.
00001 #include <list> /* required, to expose allocator */
00002 #include <stdexcept>
00003 #include <stdio.h>
00004 
00005 using namespace std;
00006 
00007 struct BigStruct
00008 {
00009   char _data[4096];
00010 };
00011 
00012 void bad_alloc_test()
00013 {
00014   typedef allocator<BigStruct> BigStructAllocType;
00015   BigStructAllocType bigStructAlloc;
00016 
00017   try {
00018     //Lets try to allocate almost 4096 Go (on most of the platforms) of memory:
00019     BigStructAllocType::pointer pbigStruct = bigStructAlloc.allocate(1024 * 1024 * 1024);
00020 
00021     // CPPUNIT_ASSERT( pbigStruct != 0 && "Allocation failed but no exception thrown" );
00022   }
00023   catch (bad_alloc const&) {
00024     printf( "Ok\n" );
00025   }
00026   catch (...) {
00027     //We shouldn't be there:
00028     // CPPUNIT_ASSERT( false && "Not bad_alloc exception thrown." );
00029   }
00030 }
00031 
00032 void bad_alloc_test1()
00033 {
00034   try {
00035     allocator<BigStruct> all;
00036     BigStruct *bs = all.allocate(1024*1024*1024);
00037 
00038     // throw bad_alloc();
00039   }
00040   catch ( bad_alloc const & ) {
00041     printf( "I am here\n" );
00042   }
00043   catch ( ... ) {
00044   }
00045 }
00046 
00047 int main()
00048 {
00049   bad_alloc_test();
00050 #if 0
00051   try {
00052     throw bad_alloc();
00053   }
00054   catch ( bad_alloc& ) {
00055   }
00056   catch ( ... ) {
00057   }
00058 #endif
00059   return 0;
00060 }

Generated on Sun May 27 2012 04:35:14 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.