ReactOS  0.4.14-dev-57-g333b8f1
eh.cc
Go to the documentation of this file.
1 #include <list> /* required, to expose allocator */
2 #include <stdexcept>
3 #include <stdio.h>
4 
5 using namespace std;
6 
7 struct BigStruct
8 {
9  char _data[4096];
10 };
11 
13 {
14  typedef allocator<BigStruct> BigStructAllocType;
15  BigStructAllocType bigStructAlloc;
16 
17  try {
18  //Lets try to allocate almost 4096 Go (on most of the platforms) of memory:
19  BigStructAllocType::pointer pbigStruct = bigStructAlloc.allocate(1024 * 1024 * 1024);
20 
21  // CPPUNIT_ASSERT( pbigStruct != 0 && "Allocation failed but no exception thrown" );
22  }
23  catch (bad_alloc const&) {
24  printf( "Ok\n" );
25  }
26  catch (...) {
27  //We shouldn't be there:
28  // CPPUNIT_ASSERT( false && "Not bad_alloc exception thrown." );
29  }
30 }
31 
33 {
34  try {
36  BigStruct *bs = all.allocate(1024*1024*1024);
37 
38  // throw bad_alloc();
39  }
40  catch ( bad_alloc const & ) {
41  printf( "I am here\n" );
42  }
43  catch ( ... ) {
44  }
45 }
46 
47 int main()
48 {
50 #if 0
51  try {
52  throw bad_alloc();
53  }
54  catch ( bad_alloc& ) {
55  }
56  catch ( ... ) {
57  }
58 #endif
59  return 0;
60 }
void bad_alloc_test()
Definition: eh.cc:12
GLsizei const GLvoid * pointer
Definition: glext.h:5848
Definition: eh.cc:7
Definition: features.h:417
void bad_alloc_test1()
Definition: eh.cc:32
_Tp * allocate(size_type __n, const void *=0)
Definition: _alloc.h:301
int main()
Definition: eh.cc:47
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
#define printf
Definition: config.h:203