annotate run/d/delete_12_D.d @ 834:4a37bb21b9a1

Nick <Nick_member@pathlink.com> 2006-02-15 news:dsv036$qlt$1@digitaldaemon.com
author thomask
date Thu, 16 Feb 2006 11:41:35 +0000
parents
children b3da1b510a19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
834
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
1 // $HeadURL$
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
2 // $Date$
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
3 // $Author$
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
4
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
5 // @author@ Nick <Nick_member@pathlink.com>
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
6 // @date@ 2006-02-15
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
7 // @uri@ news:dsv036$qlt$1@digitaldaemon.com
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
8
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
9 // @WARNING@ direct use of Phobos
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
10
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
11 module dstress.run.d.delete_12_D;
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
12
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
13 import std.c.stdlib;
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
14 import std.outofmemory;
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
15 import std.gc;
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
16
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
17 int status;
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
18
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
19 class Foo{
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
20 int i;
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
21
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
22 new(size_t sz){
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
23 void* p;
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
24
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
25 p = malloc(sz);
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
26
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
27 if (!p){
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
28 throw new OutOfMemoryException();
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
29 }
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
30
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
31 if(status++ != 1){
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
32 assert(0);
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
33 }
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
34
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
35 return p;
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
36 }
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
37
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
38 delete(void* p){
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
39 if(status++ != 2){
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
40 assert(0);
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
41 }
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
42 }
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
43 }
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
44
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
45 void test(){
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
46 auto Foo f = new Foo();
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
47 delete f;
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
48 }
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
49
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
50 int main(){
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
51 if(status++ != 0){
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
52 assert(0);
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
53 }
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
54
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
55 test();
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
56
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
57 if(status++ != 3){
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
58 assert(0);
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
59 }
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
60
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
61 return 0;
4a37bb21b9a1 Nick <Nick_member@pathlink.com>
thomask
parents:
diff changeset
62 }