ReactOS 0.4.15-dev-5669-g09dde2c
eh.cc File Reference
#include <list>
#include <stdexcept>
#include <stdio.h>
Include dependency graph for eh.cc:

Go to the source code of this file.

Classes

struct  BigStruct
 

Functions

void bad_alloc_test ()
 
void bad_alloc_test1 ()
 
int main ()
 

Function Documentation

◆ bad_alloc_test()

void bad_alloc_test ( )

Definition at line 12 of file eh.cc.

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}
_Tp * allocate(size_type __n, const void *=0)
Definition: _alloc.h:301
#define printf
Definition: freeldr.h:94

Referenced by main().

◆ bad_alloc_test1()

void bad_alloc_test1 ( )

Definition at line 32 of file eh.cc.

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}
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
Definition: eh.cc:8

◆ main()

int main ( void  )

Definition at line 47 of file eh.cc.

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