Overview
Context
Changes
Modified src/Makefile
from [91906e0bb6]
to [2b071b3432].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
-
+
-
+
|
LIB = ${LIB_PREFIX}objfw${LIB_SUFFIX}
LIB_MAJOR = 1
LIB_MINOR = 0
SRCS = OFConstString.m \
OFConstWideString.m \
OFException.m \
OFExceptions.m \
OFList.m \
OFListObject.m \
OFObject.m \
OFString.m \
OFWideString.m
INCLUDES = OFConstString.h \
OFConstWideString.h \
OFException.h \
OFExceptions.h \
OFList.h \
OFListObject.h \
OFObject.h \
OFString.h \
OFWideString.h
include ../buildsys.mk
OBJCFLAGS += ${LIB_CFLAGS}
LD = ${OBJC}
LDFLAGS += ${LIB_LDFLAGS}
LIBS += -lobjc
|
Deleted src/OFException.h version [aab3ba4a15].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of libobjfw. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE included in
* the packaging of this file.
*/
#define __NO_OFEXCEPTION
#import "OFObject.h"
@interface OFException: OFObject
@end
|
Deleted src/OFException.m version [6e35154e42].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of libobjfw. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE included in
* the packaging of this file.
*/
#import "OFException.h"
@implementation OFException
@end
|
Added src/OFExceptions.h version [03ab1df298].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2008
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of libobjfw. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE included in
* the packaging of this file.
*/
#import <stddef.h>
#import "OFObject.h"
@interface OFException: OFObject
+ new: (id)obj;
- init: (id)obj;
@end
@interface OFNoMemException: OFException
+ new: (id)obj
withSize: (size_t)size;
- init: (id)obj
withSize: (size_t)size;
@end
@interface OFMemNotPartOfObjException: OFException
+ new: (id)obj
withPtr: (void*)ptr;
- init: (id)obj
withPtr: (void*)ptr;
@end
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Added src/OFExceptions.m version [2ea46496b5].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
61
62
63
64
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2008
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of libobjfw. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE included in
* the packaging of this file.
*/
#import <stdio.h>
#import "OFExceptions.h"
@implementation OFException
+ new: (id)obj
{
return [[OFException alloc] init: obj];
}
- init: (id)obj
{
return [super init];
}
@end
@implementation OFNoMemException
+ new: (id)obj
withSize: (size_t)size
{
return [[OFNoMemException alloc] init: obj
withSize: size];
}
- init: (id)obj
withSize: (size_t)size
{
fprintf(stderr, "ERROR: Could not allocate %zd byte for object %s!\n ",
size, [obj name]);
return [super init];
}
@end
@implementation OFMemNotPartOfObjException
+ new: (id)obj
withPtr: (void*)ptr
{
return [[OFMemNotPartOfObjException alloc] init: obj
withPtr: ptr];
}
- init: (id)obj
withPtr: (void*)ptr
{
fprintf(stderr, "ERROR: Memory at %p was not allocated as part of "
"object %s!\n"
"ERROR: -> Not changing memory allocation!\n"
"ERROR: (Hint: It is possible that you tried to free the same "
"memory twice!)\n", ptr, [obj name]);
return [super init];
}
@end
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Modified src/OFObject.h
from [55682be82c]
to [b47bfb1d54].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
25
26
27
28
29
30
31
|
-
-
-
-
-
-
-
-
-
-
-
|
- init;
- (void*)getMem: (size_t)size;
- (void*)resizeMem: (void*)ptr
toSize: (size_t)size;
- (void)freeMem: (void*)ptr;
- free;
@end
#ifndef __NO_OFEXCEPTION
#import "OFException.h"
@interface OFMemNotPartOfObjException: OFException
+ new: (void*)p
fromObject: (id)obj;
- init: (void*)p
fromObject: (id)obj;
@end
#endif
|
Modified src/OFObject.m
from [9572084d4f]
to [0937ee4297].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
|
-
+
-
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2008
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of libobjfw. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE included in
* the packaging of this file.
*/
#import <stdio.h>
#import <stdlib.h>
#import "OFObject.h"
#import "OFExceptions.h"
@implementation OFObject
- init
{
if ((self = [super init]) != nil)
__mem_pool = NULL;
return self;
}
- (void*)getMem: (size_t)size
{
struct __ofobject_allocated_mem *iter;
if ((iter = malloc(sizeof(struct __ofobject_allocated_mem))) == NULL)
if ((iter = malloc(sizeof(struct __ofobject_allocated_mem))) == NULL) {
@throw [OFNoMemException new: self
withSize: sizeof(
struct __ofobject_allocated_mem)];
return NULL;
}
if ((iter->ptr = malloc(size)) == NULL) {
free(iter);
@throw [OFNoMemException new: self
withSize: size];
return NULL;
}
iter->next = NULL;
iter->prev = __mem_pool;
if (__mem_pool != NULL)
|
︙ | | |
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
-
+
+
+
+
-
+
+
|
- (void*)resizeMem: (void*)ptr
toSize: (size_t)size
{
struct __ofobject_allocated_mem *iter;
for (iter = __mem_pool; iter != NULL; iter = iter->prev) {
if (iter->ptr == ptr) {
if ((ptr = realloc(iter->ptr, size)) == NULL)
if ((ptr = realloc(iter->ptr, size)) == NULL) {
@throw [OFNoMemException new: self
withSize: size];
return NULL;
}
iter->ptr = ptr;
return ptr;
}
}
@throw [OFMemNotPartOfObjException new: ptr fromObject: self];
@throw [OFMemNotPartOfObjException new: self
withPtr: ptr];
return NULL;
}
- (void)freeMem: (void*)ptr;
{
struct __ofobject_allocated_mem *iter;
|
︙ | | |
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
free(iter);
free(ptr);
return;
}
}
@throw [OFMemNotPartOfObjException new: ptr fromObject: self];
@throw [OFMemNotPartOfObjException new: self
withPtr: ptr];
}
- free
{
struct __ofobject_allocated_mem *iter, *iter2;
for (iter = __mem_pool; iter != NULL; iter = iter2) {
iter2 = iter->prev;
free(iter->ptr);
free(iter);
}
return [super free];
}
@end
@implementation OFMemNotPartOfObjException
+ new: (void*)ptr fromObject: (id)obj
{
return [[OFMemNotPartOfObjException alloc] init: ptr
fromObject: obj];
}
- init: (void*)ptr fromObject: (id)obj
{
fprintf(stderr, "ERROR: Memory at %p was not allocated as part of "
"object %s!\n"
"ERROR: -> Not changing memory allocation!\n"
"ERROR: (Hint: It is possible that you tried to free the same "
"memory twice!)\n", ptr, [obj name]);
return [super init];
}
@end
|
Modified src/OFString.m
from [1c1ae2a28e]
to [fb3d19ec1b].
︙ | | |
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
+
|
* Q Public License 1.0, which can be found in the file LICENSE included in
* the packaging of this file.
*/
#import <stdlib.h>
#import <string.h>
#import "OFString.h"
#import "OFExceptions.h"
@implementation OFString
+ new: (const char*)str
{
return [[OFString alloc] init: str];
}
|
︙ | | |
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
-
-
-
+
+
-
|
if (str == NULL)
return [self setTo:str];
strlength = strlen(str);
newlen = length + strlength;
/* FIXME: Add error handling */
if ((newstr = [self resizeMem: string
toSize: newlen + 1]) == NULL)
newstr = [self resizeMem: string
toSize: newlen + 1];
return nil;
memcpy(newstr + length, str, strlength + 1);
length = newlen;
string = newstr;
return self;
}
@end
|
Modified src/OFWideString.m
from [8978f6afd4]
to [a3637e3c40].
︙ | | |
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
+
|
* the packaging of this file.
*/
#import <stdlib.h>
#import <string.h>
#import <wchar.h>
#import "OFWideString.h"
#import "OFExceptions.h"
@implementation OFWideString
+ new: (const wchar_t*)wstr
{
return [[OFWideString alloc] init: wstr];
}
|
︙ | | |
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
-
-
-
+
+
-
|
if (wstr == NULL)
return [self setTo: wstr];
strlength = wcslen(wstr);
newlen = length + strlength;
/* FIXME: Add error handling */
if ((newstr = [self resizeMem: wstring
toSize: (newlen + 1) * sizeof(wchar_t)]) == NULL)
newstr = [self resizeMem: wstring
toSize: (newlen + 1) * sizeof(wchar_t)];
return nil;
memcpy(newstr + length, wstr, (strlength + 1) * sizeof(wchar_t));
length = newlen;
wstring = newstr;
return self;
}
@end
|
Modified tests/OFObject/OFObject.m
from [2c9d4130c6]
to [b4bf13ad01].
︙ | | |
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
+
|
*/
#import <stdio.h>
#import <stdlib.h>
#import <stdbool.h>
#import "OFObject.h"
#import "OFExceptions.h"
int
main()
{
OFObject *obj = [OFObject new];
bool caught;
void *p, *q, *r;
|
︙ | | |