ObjFW  Check-in [8ae4c59cd6]

Overview
Comment:Return self when we have no return value. This allows nesting.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8ae4c59cd60267d832749e5e6a8441da28c5111b2eba0a5a5ebba435680e6302
User & Date: js on 2008-10-26 20:54:54
Other Links: manifest | tags
Context
2008-10-28
18:19
Add #undefs in OFHashes. check-in: 9759533b97 user: js tags: trunk
2008-10-26
20:54
Return self when we have no return value. This allows nesting. check-in: 8ae4c59cd6 user: js tags: trunk
19:35
Add OFSHA1Hash. check-in: 631895440e user: js tags: trunk
Changes

Modified src/OFExceptions.h from [03939ec239] to [039a0e8d07].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
	char *errstr;
}

+ newWithObject: (id)obj;
- initWithObject: (id)obj;
- free;
- (void)raise;
- (char*)string;
@end

@interface OFNoMemException: OFException
+ newWithObject: (id)obj
	andSize: (size_t)size;
- initWithObject: (id)obj







|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
	char *errstr;
}

+ newWithObject: (id)obj;
- initWithObject: (id)obj;
- free;
- raise;
- (char*)string;
@end

@interface OFNoMemException: OFException
+ newWithObject: (id)obj
	andSize: (size_t)size;
- initWithObject: (id)obj

Modified src/OFExceptions.m from [b3c8864639] to [c11f760527].

46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
{
	if (errstr != NULL)
		free(errstr);

	return [super free];
}

- (void)raise
{
	@throw self;

}

- (char*)string
{
	return errstr;
}
@end







|


>







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{
	if (errstr != NULL)
		free(errstr);

	return [super free];
}

- raise
{
	@throw self;
	return self;
}

- (char*)string
{
	return errstr;
}
@end

Modified src/OFList.h from [f955344801] to [71b17c2d3e].

19
20
21
22
23
24
25
26
27
28
}

- init;
- free;
- freeIncludingData;
- (OFListObject*)first;
- (OFListObject*)last;
- (void)add: (OFListObject*)ptr;
- (void)addNew: (void*)ptr;
@end







|
|

19
20
21
22
23
24
25
26
27
28
}

- init;
- free;
- freeIncludingData;
- (OFListObject*)first;
- (OFListObject*)last;
- add: (OFListObject*)ptr;
- addNew: (void*)ptr;
@end

Modified src/OFList.m from [361533dbeb] to [dffe6b716b].

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
}

- (OFListObject*)last
{
	return last;
}

- (void)add: (OFListObject*)ptr
{
	if (!first || !last) {
		first = last = ptr;
		return;
	}

	[ptr setPrev: last];
	[last setNext: ptr];

	last = ptr;
}



- (void)addNew: (void*)ptr
{
	return [self add: [OFListObject newWithData: ptr]];
}
@end







|



|






|
>
|
>
|




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
}

- (OFListObject*)last
{
	return last;
}

- add: (OFListObject*)ptr
{
	if (!first || !last) {
		first = last = ptr;
		return self;
	}

	[ptr setPrev: last];
	[last setNext: ptr];

	last = ptr;

	return self;
}

- addNew: (void*)ptr
{
	return [self add: [OFListObject newWithData: ptr]];
}
@end

Modified src/OFListObject.h from [7460e3daf6] to [b3500fd953].

20
21
22
23
24
25
26
27
28
29

+ newWithData: (void*)ptr;
- initWithData: (void*)ptr;
- freeIncludingData;
- (void*)data;
- (OFListObject*)next;
- (OFListObject*)prev;
- (void)setNext: (OFListObject*)ptr;
- (void)setPrev: (OFListObject*)ptr;
@end







|
|

20
21
22
23
24
25
26
27
28
29

+ newWithData: (void*)ptr;
- initWithData: (void*)ptr;
- freeIncludingData;
- (void*)data;
- (OFListObject*)next;
- (OFListObject*)prev;
- setNext: (OFListObject*)ptr;
- setPrev: (OFListObject*)ptr;
@end

Modified src/OFListObject.m from [ed517ec6ff] to [df0e83b386].

48
49
50
51
52
53
54
55
56
57

58
59
60
61
62

63
64
}

- (OFListObject*)prev
{
	return prev;
}

- (void)setNext: (OFListObject*)ptr
{
	next = ptr;

}

- (void)setPrev: (OFListObject*)ptr
{
	prev = ptr;

}
@end







|


>


|


>


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
}

- (OFListObject*)prev
{
	return prev;
}

- setNext: (OFListObject*)ptr
{
	next = ptr;
	return self;
}

- setPrev: (OFListObject*)ptr
{
	prev = ptr;
	return self;
}
@end

Modified src/OFObject.h from [20796294ad] to [1168f25909].

22
23
24
25
26
27
28
29
30
31
	struct __ofobject_allocated_mem *__mem_pool;
}

- init;
- (void*)getMemWithSize: (size_t)size;
- (void*)resizeMem: (void*)ptr
	    toSize: (size_t)size;
- (void)freeMem: (void*)ptr;
- free;
@end







|


22
23
24
25
26
27
28
29
30
31
	struct __ofobject_allocated_mem *__mem_pool;
}

- init;
- (void*)getMemWithSize: (size_t)size;
- (void*)resizeMem: (void*)ptr
	    toSize: (size_t)size;
- freeMem: (void*)ptr;
- free;
@end

Modified src/OFObject.m from [88dde3fe42] to [fdc15c6565].

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
122
123


124
	}

	[[OFMemNotPartOfObjException newWithObject: self
					andPointer: ptr] raise];
	return NULL;
}

- (void)freeMem: (void*)ptr;
{
	struct __ofobject_allocated_mem *iter;

	for (iter = __mem_pool; iter != NULL; iter = iter->prev) {
		if (iter->ptr == ptr) {
			if (iter->prev != NULL) 
				iter->prev->next = iter->next;
			if (iter->next != NULL)
				iter->next->prev = iter->prev;
			if (__mem_pool == iter)
				__mem_pool = NULL;

			free(iter);
			free(ptr);

			return;
		}
	}

	[[OFMemNotPartOfObjException newWithObject: self
					andPointer: ptr] raise];
}


@end







|















|





|
>
>

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
122
123
124
125
126
	}

	[[OFMemNotPartOfObjException newWithObject: self
					andPointer: ptr] raise];
	return NULL;
}

- freeMem: (void*)ptr;
{
	struct __ofobject_allocated_mem *iter;

	for (iter = __mem_pool; iter != NULL; iter = iter->prev) {
		if (iter->ptr == ptr) {
			if (iter->prev != NULL) 
				iter->prev->next = iter->next;
			if (iter->next != NULL)
				iter->next->prev = iter->prev;
			if (__mem_pool == iter)
				__mem_pool = NULL;

			free(iter);
			free(ptr);

			return self;
		}
	}

	[[OFMemNotPartOfObjException newWithObject: self
					andPointer: ptr] raise];

	return self;
}
@end