35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
OFObject *obj = [OFObject new];
bool caught;
void *p, *q, *r;
/* Test freeing memory not allocated by obj */
puts("Freeing memory not allocated by object (should throw an "
"exception)...");
CATCH_EXCEPTION([obj freeMem: (void*)123], OFMemNotPartOfObjException)
/* Test allocating memory */
puts("Allocating memory through object...");
p = [obj getMem: 4096];
puts("Allocated 4096 bytes.");
/* Test freeing the just allocated memory */
|
|
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
OFObject *obj = [OFObject new];
bool caught;
void *p, *q, *r;
/* Test freeing memory not allocated by obj */
puts("Freeing memory not allocated by object (should throw an "
"exception)...");
CATCH_EXCEPTION([obj freeMem: NULL], OFMemNotPartOfObjException)
/* Test allocating memory */
puts("Allocating memory through object...");
p = [obj getMem: 4096];
puts("Allocated 4096 bytes.");
/* Test freeing the just allocated memory */
|