ReactOS
0.4.15-dev-1636-gf634010
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
12
void
bad_alloc_test
()
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
32
void
bad_alloc_test1
()
33
{
34
try
{
35
allocator<BigStruct>
all;
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
{
49
bad_alloc_test
();
50
#if 0
51
try
{
52
throw
bad_alloc();
53
}
54
catch
( bad_alloc& ) {
55
}
56
catch
( ... ) {
57
}
58
#endif
59
return
0;
60
}
bad_alloc_test
void bad_alloc_test()
Definition:
eh.cc:12
pointer
GLsizei const GLvoid * pointer
Definition:
glext.h:5848
BigStruct
Definition:
eh.cc:7
std
Definition:
features.h:417
allocator
Definition:
_alloc.h:270
bad_alloc_test1
void bad_alloc_test1()
Definition:
eh.cc:32
allocator::allocate
_Tp * allocate(size_type __n, const void *=0)
Definition:
_alloc.h:301
main
int main()
Definition:
eh.cc:47
bs
static struct msdos_boot_sector bs
Definition:
mkdosfs.c:539
printf
#define printf
Definition:
config.h:203
sdk
lib
3rdparty
stlport
test
compiler
eh.cc
Generated on Sun Jan 24 2021 06:08:40 for ReactOS by
1.8.15