Index: src/OFConstString.h ================================================================== --- src/OFConstString.h +++ src/OFConstString.h @@ -12,17 +12,15 @@ #import #import "OFObject.h" @interface OFConstString: OFObject { - const char *string; - size_t length; + const char *string; + size_t length; } -+ new:(const char*)str; ++ new: (const char*)str; - init; -- init:(const char*)str; +- init: (const char*)str; - (const char*)cString; - (size_t)length; @end - -/* vim: se syn=objc: */ Index: src/OFConstString.m ================================================================== --- src/OFConstString.m +++ src/OFConstString.m @@ -11,21 +11,21 @@ #import #import "OFConstString.h" @implementation OFConstString -+ new:(const char*)str ++ new: (const char*)str { - return [[OFConstString alloc] init:str]; + return [[OFConstString alloc] init: str]; } - init { - return [self init:NULL]; + return [self init: NULL]; } -- init:(const char*)str +- init: (const char*)str { if ((self = [super init])) { if (str == NULL) { length = 0; string = NULL; Index: src/OFConstWideString.h ================================================================== --- src/OFConstWideString.h +++ src/OFConstWideString.h @@ -13,17 +13,15 @@ #import #import "OFObject.h" @interface OFConstWideString: OFObject { - const wchar_t *wstring; - size_t length; + const wchar_t *wstring; + size_t length; } -+ new:(const wchar_t*)wstr; ++ new: (const wchar_t*)wstr; - init; -- init:(const wchar_t*)wstr; +- init: (const wchar_t*)wstr; - (const wchar_t*)wcString; - (size_t)length; @end - -/* vim: se syn=objc: */ Index: src/OFConstWideString.m ================================================================== --- src/OFConstWideString.m +++ src/OFConstWideString.m @@ -11,21 +11,21 @@ #import #import "OFConstWideString.h" @implementation OFConstWideString -+ new:(const wchar_t*)wstr ++ new: (const wchar_t*)wstr { - return [[OFConstWideString alloc] init:wstr]; + return [[OFConstWideString alloc] init: wstr]; } - init { - return [self init:NULL]; + return [self init: NULL]; } -- init:(const wchar_t*)wstr +- init: (const wchar_t*)wstr { if ((self = [super init])) { if (wstr == NULL) { length = 0; wstring = NULL; Index: src/OFList.h ================================================================== --- src/OFList.h +++ src/OFList.h @@ -12,19 +12,17 @@ #import "OFObject.h" #import "OFListObject.h" @interface OFList: OFObject { - OFListObject *first; - OFListObject *last; + OFListObject *first; + OFListObject *last; } - init; - free; - freeWithData; - (OFListObject*)first; - (OFListObject*)last; -- (void)add:(OFListObject*)ptr; -- (void)addNew:(void*)ptr; +- (void)add: (OFListObject*)ptr; +- (void)addNew: (void*)ptr; @end - -/* vim: se syn=objc: */ Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -54,23 +54,23 @@ - (OFListObject*)last { return last; } -- (void)add:(OFListObject*)ptr +- (void)add: (OFListObject*)ptr { if (!first || !last) { first = last = ptr; return; } - [ptr setPrev:last]; - [last setNext:ptr]; + [ptr setPrev: last]; + [last setNext: ptr]; last = ptr; } -- (void)addNew:(void*)ptr +- (void)addNew: (void*)ptr { - return [self add:[OFListObject new:ptr]]; + return [self add: [OFListObject new: ptr]]; } @end Index: src/OFListObject.h ================================================================== --- src/OFListObject.h +++ src/OFListObject.h @@ -11,21 +11,19 @@ #import "OFObject.h" @interface OFListObject: OFObject { - void *data; - OFListObject *next; - OFListObject *prev; + void *data; + OFListObject *next; + OFListObject *prev; } -+ new:(void*)ptr; -- init:(void*)ptr; ++ new: (void*)ptr; +- init: (void*)ptr; - freeWithData; - (void*)data; - (OFListObject*)next; - (OFListObject*)prev; -- (void)setNext:(OFListObject*)ptr; -- (void)setPrev:(OFListObject*)ptr; +- (void)setNext: (OFListObject*)ptr; +- (void)setPrev: (OFListObject*)ptr; @end - -/* vim: se syn=objc: */ Index: src/OFListObject.m ================================================================== --- src/OFListObject.m +++ src/OFListObject.m @@ -11,16 +11,16 @@ #import #import "OFListObject.h" @implementation OFListObject -+ new:(void*)ptr ++ new: (void*)ptr { - return [[OFListObject alloc] init:ptr]; + return [[OFListObject alloc] init: ptr]; } -- init:(void*)ptr +- init: (void*)ptr { if ((self = [super init])) { next = nil; prev = nil; data = ptr; @@ -48,15 +48,15 @@ - (OFListObject*)prev { return prev; } -- (void)setNext:(OFListObject*)ptr +- (void)setNext: (OFListObject*)ptr { next = ptr; } -- (void)setPrev:(OFListObject*)ptr +- (void)setPrev: (OFListObject*)ptr { prev = ptr; } @end Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -10,11 +10,11 @@ */ #import struct __ofobject_allocated_mem { - void *ptr; + void *ptr; struct __ofobject_allocated_mem *prev; struct __ofobject_allocated_mem *next; }; @interface OFObject: Object @@ -21,10 +21,11 @@ { struct __ofobject_allocated_mem *__mem_pool; } - init; -- (void*)getMem:(size_t)size; -- (void*)resizeMem:(void*)ptr toSize:(size_t)size; -- (void)freeMem:(void*)ptr; +- (void*)getMem: (size_t)size; +- (void*)resizeMem: (void*)ptr + toSize: (size_t)size; +- (void)freeMem: (void*)ptr; - free; @end Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -20,11 +20,11 @@ if ((self = [super init]) != nil) __mem_pool = NULL; return self; } -- (void*)getMem:(size_t)size +- (void*)getMem: (size_t)size { struct __ofobject_allocated_mem *iter; if ((iter = malloc(sizeof(struct __ofobject_allocated_mem))) == NULL) return NULL; @@ -43,11 +43,12 @@ __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) { @@ -58,16 +59,16 @@ 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; +- (void)freeMem: (void*)ptr; { struct __ofobject_allocated_mem *iter; for (iter = __mem_pool; iter != NULL; iter = iter->prev) { if (iter->ptr == ptr) { @@ -82,11 +83,11 @@ 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; Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -12,20 +12,18 @@ #import #import "OFObject.h" @interface OFString: OFObject { - char *string; - size_t length; + char *string; + size_t length; } -+ new:(const char*)str; ++ new: (const char*)str; - init; -- init:(const char*)str; +- init: (const char*)str; - (char*)cString; - (size_t)length; -- (OFString*)setTo:(const char*)str; +- (OFString*)setTo: (const char*)str; - (OFString*)clone; -- (OFString*)append:(const char*)str; +- (OFString*)append: (const char*)str; @end - -/* vim: se syn=objc: */ Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -12,29 +12,29 @@ #import #import #import "OFString.h" @implementation OFString -+ new:(const char*)str ++ new: (const char*)str { - return [[OFString alloc] init:str]; + return [[OFString alloc] init: str]; } - init { - return [self init:NULL]; + return [self init: NULL]; } -- init:(const char*)str +- init: (const char*)str { if ((self = [super init])) { if (str == NULL) { length = 0; string = NULL; } else { length = strlen(str); - if ((string = [self getMem:length]) == NULL) + if ((string = [self getMem: length]) == NULL) return NULL; memcpy(string, str, length); } } return self; @@ -48,58 +48,58 @@ - (size_t)length { return length; } -- (OFString*)setTo:(const char*)str +- (OFString*)setTo: (const char*)str { char *newstr; size_t newlen; if (str == NULL) { - [self freeMem:string]; + [self freeMem: string]; length = 0; string = NULL; return self; } newlen = strlen(str); - if ((newstr = [self getMem:newlen]) == NULL) + if ((newstr = [self getMem: newlen]) == NULL) return nil; memcpy(newstr, str, newlen); if (string != NULL) - [self freeMem:string]; + [self freeMem: string]; length = newlen; string = newstr; return self; } - (OFString*)clone { - return [OFString new:string]; + return [OFString new: string]; } - (OFString*)append: (const char*)str { - char *newstr; - size_t newlen, strlength; + char *newstr; + size_t newlen, strlength; 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 */ + /* 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'; Index: src/OFWideString.h ================================================================== --- src/OFWideString.h +++ src/OFWideString.h @@ -17,16 +17,14 @@ { wchar_t *wstring; size_t length; } -+ new:(const wchar_t*)wstr; ++ new: (const wchar_t*)wstr; - init; -- init:(const wchar_t*)wstr; +- init: (const wchar_t*)wstr; - (wchar_t*)wcString; - (size_t)length; -- (OFWideString*)setTo:(const wchar_t*)wstr; +- (OFWideString*)setTo: (const wchar_t*)wstr; - (OFWideString*)clone; -- (OFWideString*)append:(const wchar_t*)wstr; +- (OFWideString*)append: (const wchar_t*)wstr; @end - -/* vim: se syn=objc: */ Index: src/OFWideString.m ================================================================== --- src/OFWideString.m +++ src/OFWideString.m @@ -13,30 +13,30 @@ #import #import #import "OFWideString.h" @implementation OFWideString -+ new:(const wchar_t*)wstr ++ new: (const wchar_t*)wstr { - return [[OFWideString alloc] init:wstr]; + return [[OFWideString alloc] init: wstr]; } - init { - return [self init:NULL]; + return [self init: NULL]; } -- init:(const wchar_t*)wstr +- init: (const wchar_t*)wstr { if ((self = [super init])) { if (wstr == NULL) { length = 0; wstring = NULL; } else { length = wcslen(wstr); if ((wstring = - [self getMem:length * sizeof(wchar_t)]) == NULL) + [self getMem: length * sizeof(wchar_t)]) == NULL) return NULL; memcpy(wstring, wstr, length * sizeof(wchar_t)); } } return self; @@ -50,11 +50,11 @@ - (size_t)length { return length; } -- (OFWideString*)setTo:(const wchar_t*)wstr +- (OFWideString*)setTo: (const wchar_t*)wstr { wchar_t *newstr; size_t newlen; if (wstr == NULL) { @@ -65,44 +65,43 @@ return self; } newlen = wcslen(wstr); - if ((newstr = [self getMem:newlen * sizeof(wchar_t)]) == NULL) + if ((newstr = [self getMem: newlen * sizeof(wchar_t)]) == NULL) return nil; memcpy(newstr, wstr, newlen * sizeof(wchar_t)); if (wstring != NULL) - [self freeMem:wstring]; + [self freeMem: wstring]; length = newlen; wstring = newstr; return self; } - (OFWideString*)clone { - return [OFWideString new:wstring]; + return [OFWideString new: wstring]; } - (OFWideString*)append: (const wchar_t*)wstr { wchar_t *newstr; size_t newlen, strlength; if (wstr == NULL) - return [self setTo:wstr]; + return [self setTo: wstr]; strlength = wcslen(wstr); newlen = length + strlength; - if ((newstr = [self resizeMem:wstring toSize:(newlen + 1) * - sizeof(wchar_t)]) == NULL) { - /* FIXME: Add error handling */ + /* FIXME: Add error handling */ + if ((newstr = [self resizeMem: wstring + toSize: newlen * sizeof(wchar_t) + 2]) == NULL) return nil; - } wstring = newstr; memcpy(wstring + length * sizeof(wchar_t), wstr, strlength * sizeof(wchar_t)); Index: tests/OFList/OFList.m ================================================================== --- tests/OFList/OFList.m +++ tests/OFList/OFList.m @@ -15,12 +15,12 @@ #import "OFList.h" int main() { - OFList *list; - OFListObject *iter; + OFList *list; + OFListObject *iter; list = [OFList new]; [list addNew: [OFString new: "First String Object"]]; [list addNew: [OFString new: "Second String Object"]]; Index: tests/OFString/OFString.m ================================================================== --- tests/OFString/OFString.m +++ tests/OFString/OFString.m @@ -15,19 +15,19 @@ #import "OFString.h" int main() { - OFString *s1 = [OFString new:"foo"]; - OFString *s2 = [[OFString alloc] init:""]; + OFString *s1 = [OFString new: "foo"]; + OFString *s2 = [[OFString alloc] init: ""]; OFString *s3; OFString *s4 = [OFString new]; - [s2 append:"bar"]; + [s2 append: "bar"]; s3 = [s1 clone]; - [s4 setTo:[s2 cString]]; + [s4 setTo: [s2 cString]]; printf("s1 = %s\n", [s1 cString]); printf("s2 = %s\n", [s2 cString]); printf("s3 = %s\n", [s3 cString]); printf("s4 = %s\n", [s4 cString]); Index: tests/OFWideString/OFWideString.m ================================================================== --- tests/OFWideString/OFWideString.m +++ tests/OFWideString/OFWideString.m @@ -15,19 +15,19 @@ #import "OFWideString.h" int main() { - OFWideString *s1 = [OFWideString new:L"foo"]; - OFWideString *s2 = [[OFWideString alloc] init:L""]; + OFWideString *s1 = [OFWideString new: L"foo"]; + OFWideString *s2 = [[OFWideString alloc] init: L""]; OFWideString *s3; OFWideString *s4 = [OFWideString new]; - printf("%p\n", [s2 append:L"bar"]); + printf("%p\n", [s2 append: L"bar"]); s3 = [s1 clone]; - [s4 setTo:[s2 wcString]]; + [s4 setTo: [s2 wcString]]; wprintf(L"s1 = %S\n", [s1 wcString]); wprintf(L"s2 = %S\n", [s2 wcString]); wprintf(L"s3 = %S\n", [s3 wcString]); wprintf(L"s4 = %S\n", [s4 wcString]);