71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/* Try to free again */
puts("Now trying to free them again...");
CATCH_EXCEPTION([obj freeMem: p], OFMemNotPartOfObjException)
CATCH_EXCEPTION([obj freeMem: q], OFMemNotPartOfObjException)
CATCH_EXCEPTION([obj freeMem: r], OFMemNotPartOfObjException)
puts("Got all 3!");
puts("Trying to allocate more memory than possible...");
CATCH_EXCEPTION(p = [obj getMemWithSize: SIZE_MAX], OFNoMemException)
puts("Allocating 1 byte...");
p = [obj getMemWithSize: 1];
puts("Trying to resize that 1 byte to more than possible...");
CATCH_EXCEPTION(p = [obj resizeMem: p
toSize: SIZE_MAX],
OFNoMemException)
puts("Trying to resize NULL to 1024 bytes...");
p = [obj resizeMem: NULL
toSize: 1024];
[obj freeMem: p];
puts("Trying to resize memory that is not part of object...");
CATCH_EXCEPTION(p = [obj resizeMem: (void*)1
toSize: 1024],
OFMemNotPartOfObjException)
/* TODO: Test if freeing object frees all memory */
return 0;
}
|
|
|
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/* Try to free again */
puts("Now trying to free them again...");
CATCH_EXCEPTION([obj freeMem: p], OFMemNotPartOfObjException)
CATCH_EXCEPTION([obj freeMem: q], OFMemNotPartOfObjException)
CATCH_EXCEPTION([obj freeMem: r], OFMemNotPartOfObjException)
puts("Got all 3!");
puts("Trying to allocate more memory than possible...");
CATCH_EXCEPTION(p = [obj getMemWithSize: SIZE_MAX], OFNoMemException)
puts("Allocating 1 byte...");
p = [obj getMemWithSize: 1];
puts("Trying to resize that 1 byte to more than possible...");
CATCH_EXCEPTION(p = [obj resizeMem: p
toSize: SIZE_MAX],
OFNoMemException)
puts("Trying to resize NULL to 1024 bytes...");
p = [obj resizeMem: NULL
toSize: 1024];
[obj freeMem: p];
puts("Trying to resize memory that is not part of object...");
CATCH_EXCEPTION(p = [obj resizeMem: (void*)1
toSize: 1024],
OFMemNotPartOfObjException)
/* TODO: Test if freeing object frees all memory */
return 0;
}
|