16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include "config.h"
#import "OFOutOfMemoryException.h"
#import "OFString.h"
@implementation OFOutOfMemoryException
+ (instancetype)exceptionWithClass: (Class)class_
requestedSize: (size_t)size
{
return [[[self alloc] initWithClass: class_
requestedSize: size] autorelease];
}
- initWithClass: (Class)class_
requestedSize: (size_t)size
{
self = [super initWithClass: class_];
requestedSize = size;
return self;
}
- (OFString*)description
{
if (description != nil)
return description;
if (requestedSize != 0)
description = [[OFString alloc] initWithFormat:
@"Could not allocate %zu bytes in class %@!", requestedSize,
inClass];
else
description = [[OFString alloc] initWithFormat:
@"Could not allocate enough memory in class %@!", inClass];
return description;
}
- (size_t)requestedSize
{
return requestedSize;
}
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include "config.h"
#import "OFOutOfMemoryException.h"
#import "OFString.h"
@implementation OFOutOfMemoryException
+ (instancetype)exceptionWithClass: (Class)class
requestedSize: (size_t)requestedSize
{
return [[[self alloc] initWithClass: class
requestedSize: requestedSize] autorelease];
}
- initWithClass: (Class)class
requestedSize: (size_t)requestedSize
{
self = [super initWithClass: class];
_requestedSize = requestedSize;
return self;
}
- (OFString*)description
{
if (_description != nil)
return _description;
if (_requestedSize != 0)
_description = [[OFString alloc] initWithFormat:
@"Could not allocate %zu bytes in class %@!",
_requestedSize, _inClass];
else
_description = [[OFString alloc] initWithFormat:
@"Could not allocate enough memory in class %@!", _inClass];
return _description;
}
- (size_t)requestedSize
{
return _requestedSize;
}
@end
|