ObjFW  Check-in [778be56179]

Overview
Comment:Coding style.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 778be56179b4a6716b7d248ed100fc63dd267eb2b6ebdc21d7bf028fcae23f59
User & Date: js on 2008-09-14 15:29:34
Other Links: manifest | tags
Context
2008-09-14
16:43
Lots of changes. See full commit message. check-in: 7b8b7cd06c user: js tags: trunk
15:29
Coding style. check-in: 778be56179 user: js tags: trunk
15:12
Fix a bug in OFWideString and add test for OFWideString. check-in: b4ead4bdd2 user: js tags: trunk
Changes

Modified src/OFConstString.h from [d944b1298b] to [f6b02d3f44].

20
21
22
23
24
25
26
27
28
20
21
22
23
24
25
26









-
-

+ new:(const char*)str;
- init;
- init:(const char*)str;
- (const char*)cString;
- (size_t)length;
@end

/* vim: se syn=objc: */

Modified src/OFConstString.m from [8c3560516b] to [76ce673d4c].

whitespace changes only

Modified src/OFConstWideString.h from [30aab21810] to [d4d5fd756d].

21
22
23
24
25
26
27
28
29
21
22
23
24
25
26
27









-
-

+ new:(const wchar_t*)wstr;
- init;
- init:(const wchar_t*)wstr;
- (const wchar_t*)wcString;
- (size_t)length;
@end

/* vim: se syn=objc: */

Modified src/OFConstWideString.m from [1ca10a0426] to [a6b7bf4dc0].

whitespace changes only

Modified src/OFList.h from [93a96d7531] to [08759996d3].

22
23
24
25
26
27
28
29
30
22
23
24
25
26
27
28









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

/* vim: se syn=objc: */

Modified src/OFList.m from [84092951f3] to [47da29ca93].

whitespace changes only

Modified src/OFListObject.h from [13cfd35f7b] to [25e264f941].

23
24
25
26
27
28
29
30
31
23
24
25
26
27
28
29









-
-
- freeWithData;
- (void*)data;
- (OFListObject*)next;
- (OFListObject*)prev;
- (void)setNext:(OFListObject*)ptr;
- (void)setPrev:(OFListObject*)ptr;
@end

/* vim: se syn=objc: */

Modified src/OFListObject.m from [0141a7e9b7] to [d372822c89].

whitespace changes only

Modified src/OFObject.h from [3d2b1446a8] to [b47bfb1d54].

20
21
22
23
24
25
26
27


28
29
30
20
21
22
23
24
25
26

27
28
29
30
31







-
+
+



@interface OFObject: Object
{
	struct __ofobject_allocated_mem *__mem_pool;
}

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

Modified src/OFObject.m from [3a6fe1669c] to [b460fe3dcf].

41
42
43
44
45
46
47
48


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

64
65
66
67
68
69
70
41
42
43
44
45
46
47

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

64
65
66
67
68
69
70
71







-
+
+














-
+







		__mem_pool->next = iter;

	__mem_pool = iter;

	return iter->ptr;
}

- (void*)resizeMem:(void*)ptr toSize:(size_t)size
- (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)
				return NULL;
			
			iter->ptr = ptr;
			return ptr;
		}
	}

	fprintf(stderr, "WARNING: Memory at %p was not allocated as part of "
	    "object %s!\n", ptr, [self name]);
	    "object %s!\n-> Memory was not resized!\n", ptr, [self name]);

	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
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95







-
+







			free(ptr);

			return;
		}
	}

	fprintf(stderr, "WARNING: Memory at %p was not allocated as part of "
	    "object %s!\n", ptr, [self name]);
	    "object %s!\n-> Memory was not free'd!\n", ptr, [self name]);
}

- free
{
	struct __ofobject_allocated_mem *iter, *iter2;

	for (iter = __mem_pool; iter != NULL; iter = iter2) {

Modified src/OFString.h from [9ae2f04448] to [362876c1c2].

23
24
25
26
27
28
29
30
31
23
24
25
26
27
28
29









-
-
- init:(const char*)str;
- (char*)cString;
- (size_t)length;
- (OFString*)setTo:(const char*)str;
- (OFString*)clone;
- (OFString*)append:(const char*)str;
@end

/* vim: se syn=objc: */

Modified src/OFString.m from [7b8481ed3a] to [52bd147dc6].

90
91
92
93
94
95
96
97
98


99
100
101
102
103
104
105
106
107
108
109
110
111
90
91
92
93
94
95
96

97
98
99
100

101
102
103
104
105
106
107
108
109
110
111







-

+
+

-












	if (str == NULL)
		return [self setTo:str];

	strlength = strlen(str);
	newlen = length + strlength;

	if ((newstr = [self resizeMem:string toSize:newlen + 1]) == NULL) {
		/* FIXME: Add error handling */
	if ((newstr = [self resizeMem: string
			       toSize: newlen + 1]) == NULL)
		return nil;
	}

	string = newstr;

	memcpy(string + length, str, strlength);
	string[newlen] = '\0';

	length = newlen;

	return self;
}
@end

Modified src/OFWideString.h from [7d19c57893] to [1f0b56cce2].

24
25
26
27
28
29
30
31
32
24
25
26
27
28
29
30









-
-
- init:(const wchar_t*)wstr;
- (wchar_t*)wcString;
- (size_t)length;
- (OFWideString*)setTo:(const wchar_t*)wstr;
- (OFWideString*)clone;
- (OFWideString*)append:(const wchar_t*)wstr;
@end

/* vim: se syn=objc: */

Modified src/OFWideString.m from [f3e926533b] to [3d87632f9d].

92
93
94
95
96
97
98

99
100


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
92
93
94
95
96
97
98
99


100
101

102

103
104
105
106
107
108
109
110
111
112
113
114







+
-
-
+
+
-

-













	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) {
	if ((newstr = [self resizeMem: wstring
			       toSize: newlen  * sizeof(wchar_t) + 2]) == NULL)
		/* FIXME: Add error handling */
		return nil;
	}

	wstring = newstr;

	memcpy(wstring + length * sizeof(wchar_t), wstr,
	    strlength * sizeof(wchar_t));
	wstring[newlen] = '\0';

	length = newlen;

	return self;
}
@end

Modified tests/OFList/OFList.m from [031f4c03f0] to [a32f1b4343].

whitespace changes only

Modified tests/OFString/OFString.m from [6917f1112f] to [04cad32cc2].

whitespace changes only

Modified tests/OFWideString/OFWideString.m from [2a8f622845] to [8d262602dc].

whitespace changes only