Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -85,13 +85,13 @@ struct pre_mem { struct pre_mem *prev, *next; id owner; }; -#define PRE_IVAR_ALIGN ((sizeof(struct pre_ivar) + \ +#define PRE_IVARS_ALIGN ((sizeof(struct pre_ivar) + \ (__BIGGEST_ALIGNMENT__ - 1)) & ~(__BIGGEST_ALIGNMENT__ - 1)) -#define PRE_IVAR ((struct pre_ivar*)(void*)((char*)self - PRE_IVAR_ALIGN)) +#define PRE_IVARS ((struct pre_ivar*)(void*)((char*)self - PRE_IVARS_ALIGN)) #define PRE_MEM_ALIGN ((sizeof(struct pre_mem) + \ (__BIGGEST_ALIGNMENT__ - 1)) & ~(__BIGGEST_ALIGNMENT__ - 1)) #define PRE_MEM(mem) ((struct pre_mem*)(void*)((char*)mem - PRE_MEM_ALIGN)) @@ -190,11 +190,11 @@ if OF_UNLIKELY (extraAlignment > 0) extraAlignment = ((instanceSize + extraAlignment - 1) & ~(extraAlignment - 1)) - extraAlignment; - instance = malloc(PRE_IVAR_ALIGN + instanceSize + + instance = malloc(PRE_IVARS_ALIGN + instanceSize + extraAlignment + extraSize); if OF_UNLIKELY (instance == nil) { alloc_failed_exception.isa = [OFAllocFailedException class]; @throw (id)&alloc_failed_exception; @@ -211,16 +211,16 @@ @throw [OFInitializationFailedException exceptionWithClass: class]; } #endif - instance = (OFObject*)((char*)instance + PRE_IVAR_ALIGN); + instance = (OFObject*)((char*)instance + PRE_IVARS_ALIGN); memset(instance, 0, instanceSize); if (!objc_constructInstance(class, instance)) { - free((char*)instance - PRE_IVAR_ALIGN); + free((char*)instance - PRE_IVARS_ALIGN); @throw [OFInitializationFailedException exceptionWithClass: class]; } if OF_UNLIKELY (extra != NULL) @@ -870,28 +870,28 @@ - (void*)allocMemoryWithSize: (size_t)size { void *pointer; struct pre_mem *preMem; - if OF_UNLIKELY (size > SIZE_MAX - PRE_IVAR_ALIGN) + if OF_UNLIKELY (size > SIZE_MAX - PRE_IVARS_ALIGN) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; if OF_UNLIKELY ((pointer = malloc(PRE_MEM_ALIGN + size)) == NULL) @throw [OFOutOfMemoryException exceptionWithClass: [self class] requestedSize: size]; preMem = pointer; preMem->owner = self; - preMem->prev = PRE_IVAR->lastMem; + preMem->prev = PRE_IVARS->lastMem; preMem->next = NULL; - if OF_LIKELY (PRE_IVAR->lastMem != NULL) - PRE_IVAR->lastMem->next = preMem; + if OF_LIKELY (PRE_IVARS->lastMem != NULL) + PRE_IVARS->lastMem->next = preMem; - if OF_UNLIKELY (PRE_IVAR->firstMem == NULL) - PRE_IVAR->firstMem = preMem; - PRE_IVAR->lastMem = preMem; + if OF_UNLIKELY (PRE_IVARS->firstMem == NULL) + PRE_IVARS->firstMem = preMem; + PRE_IVARS->lastMem = preMem; return (char*)pointer + PRE_MEM_ALIGN; } - (void*)allocMemoryWithSize: (size_t)size @@ -935,14 +935,14 @@ if OF_LIKELY (preMem->prev != NULL) preMem->prev->next = preMem; if OF_LIKELY (preMem->next != NULL) preMem->next->prev = preMem; - if OF_UNLIKELY (PRE_IVAR->firstMem == PRE_MEM(pointer)) - PRE_IVAR->firstMem = preMem; - if OF_UNLIKELY (PRE_IVAR->lastMem == PRE_MEM(pointer)) - PRE_IVAR->lastMem = preMem; + if OF_UNLIKELY (PRE_IVARS->firstMem == PRE_MEM(pointer)) + PRE_IVARS->firstMem = preMem; + if OF_UNLIKELY (PRE_IVARS->lastMem == PRE_MEM(pointer)) + PRE_IVARS->lastMem = preMem; } return (char*)new + PRE_MEM_ALIGN; } @@ -979,14 +979,14 @@ if OF_LIKELY (PRE_MEM(pointer)->prev != NULL) PRE_MEM(pointer)->prev->next = PRE_MEM(pointer)->next; if OF_LIKELY (PRE_MEM(pointer)->next != NULL) PRE_MEM(pointer)->next->prev = PRE_MEM(pointer)->prev; - if OF_UNLIKELY (PRE_IVAR->firstMem == PRE_MEM(pointer)) - PRE_IVAR->firstMem = PRE_MEM(pointer)->next; - if OF_UNLIKELY (PRE_IVAR->lastMem == PRE_MEM(pointer)) - PRE_IVAR->lastMem = PRE_MEM(pointer)->prev; + if OF_UNLIKELY (PRE_IVARS->firstMem == PRE_MEM(pointer)) + PRE_IVARS->firstMem = PRE_MEM(pointer)->next; + if OF_UNLIKELY (PRE_IVARS->lastMem == PRE_MEM(pointer)) + PRE_IVARS->lastMem = PRE_MEM(pointer)->prev; /* To detect double-free */ PRE_MEM(pointer)->owner = nil; free(PRE_MEM(pointer)); @@ -998,44 +998,44 @@ } - retain { #if defined(OF_ATOMIC_OPS) - of_atomic_inc_32(&PRE_IVAR->retainCount); + of_atomic_inc_32(&PRE_IVARS->retainCount); #elif defined(OF_THREADS) - OF_ENSURE(of_spinlock_lock(&PRE_IVAR->retainCountSpinlock)); - PRE_IVAR->retainCount++; - OF_ENSURE(of_spinlock_unlock(&PRE_IVAR->retainCountSspinlock)); + OF_ENSURE(of_spinlock_lock(&PRE_IVARS->retainCountSpinlock)); + PRE_IVARS->retainCount++; + OF_ENSURE(of_spinlock_unlock(&PRE_IVARS->retainCountSspinlock)); #else - PRE_IVAR->retainCount++; + PRE_IVARS->retainCount++; #endif return self; } - (unsigned int)retainCount { - assert(PRE_IVAR->retainCount >= 0); - return PRE_IVAR->retainCount; + assert(PRE_IVARS->retainCount >= 0); + return PRE_IVARS->retainCount; } - (void)release { #if defined(OF_ATOMIC_OPS) - if (of_atomic_dec_32(&PRE_IVAR->retainCount) <= 0) + if (of_atomic_dec_32(&PRE_IVARS->retainCount) <= 0) [self dealloc]; #elif defined(OF_THREADS) size_t c; - OF_ENSURE(of_spinlock_lock(&PRE_IVAR->retainCountSpinlock)); - c = --PRE_IVAR->retainCount; - OF_ENSURE(of_spinlock_unlock(&PRE_IVAR->retainCountSpinlock)); + OF_ENSURE(of_spinlock_lock(&PRE_IVARS->retainCountSpinlock)); + c = --PRE_IVARS->retainCount; + OF_ENSURE(of_spinlock_unlock(&PRE_IVARS->retainCountSpinlock)); if (c == 0) [self dealloc]; #else - if (--PRE_IVAR->retainCount == 0) + if (--PRE_IVARS->retainCount == 0) [self dealloc]; #endif } - autorelease @@ -1057,11 +1057,11 @@ { struct pre_mem *iter; objc_destructInstance(self); - iter = PRE_IVAR->firstMem; + iter = PRE_IVARS->firstMem; while (iter != NULL) { struct pre_mem *next = iter->next; /* * We can use owner as a sentinel to prevent exploitation in @@ -1073,11 +1073,11 @@ free(iter); iter = next; } - free((char*)self - PRE_IVAR_ALIGN); + free((char*)self - PRE_IVARS_ALIGN); } /* Required to use properties with the Apple runtime */ - copyWithZone: (void*)zone { Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -193,11 +193,11 @@ + (instancetype)stringWithUnicodeString: (const of_unichar_t*)string byteOrder: (of_byte_order_t)byteOrder length: (size_t)length; /*! - * @brief Creates a new OFString from a UTF-16 encoded string. + * @brief Creates a new OFString from a big endian UTF-16 encoded string. * * @param string The UTF-16 string * @return A new autoreleased OFString */ + (instancetype)stringWithUTF16String: (const uint16_t*)string; @@ -212,12 +212,12 @@ */ + (instancetype)stringWithUTF16String: (const uint16_t*)string byteOrder: (of_byte_order_t)byteOrder; /*! - * @brief Creates a new OFString from a UTF-16 encoded string with the specified - * length. + * @brief Creates a new OFString from a big endian UTF-16 encoded string with + * the specified length. * * @param string The UTF-16 string * @param length The length of the unicode string * @return A new autoreleased OFString */ Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -60,11 +60,11 @@ } } static OFString* transform_string(OFDataArray *cache, size_t cut, BOOL unescape, - OFObject *delegate) + id delegate) { char *cArray; size_t i, length; BOOL hasEntities = NO; OFMutableString *ret;