ReactOS 0.4.15-dev-8241-g63935f8
eh.cc
Go to the documentation of this file.
1#include <list> /* required, to expose allocator */
2#include <stdexcept>
3#include <stdio.h>
4
5using namespace std;
6
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
47int 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}
_Tp * allocate(size_type __n, const void *=0)
Definition: _alloc.h:301
void bad_alloc_test1()
Definition: eh.cc:32
void bad_alloc_test()
Definition: eh.cc:12
int main()
Definition: eh.cc:47
#define printf
Definition: freeldr.h:97
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
Definition: features.h:417
Definition: eh.cc:8
char _data[4096]
Definition: eh.cc:9