Overview
Comment: | Coding style. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6ad5d3d8d66f76f5bfd9f74bc59d2798 |
User & Date: | js on 2012-12-12 18:40:58 |
Other Links: | manifest | tags |
Context
2012-12-12
| ||
18:57 | Small conformance fix for OFHTTPServer + OFURL. check-in: 41480893fc user: js tags: trunk | |
18:40 | Coding style. check-in: 6ad5d3d8d6 user: js tags: trunk | |
2012-12-11
| ||
23:26 | OFStreamObserver_kqueue: Integer overflow check. check-in: 19df6b304d user: js tags: trunk | |
Changes
Modified src/OFObject.m from [ce3e8ba58d] to [517d28e9f2].
︙ | ︙ | |||
83 84 85 86 87 88 89 | }; struct pre_mem { struct pre_mem *prev, *next; id owner; }; | | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | }; struct pre_mem { struct pre_mem *prev, *next; id owner; }; #define PRE_IVARS_ALIGN ((sizeof(struct pre_ivar) + \ (__BIGGEST_ALIGNMENT__ - 1)) & ~(__BIGGEST_ALIGNMENT__ - 1)) #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)) static struct { Class isa; |
︙ | ︙ | |||
188 189 190 191 192 193 194 | instanceSize = class_getInstanceSize(class); if OF_UNLIKELY (extraAlignment > 0) extraAlignment = ((instanceSize + extraAlignment - 1) & ~(extraAlignment - 1)) - extraAlignment; | | | | | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | instanceSize = class_getInstanceSize(class); if OF_UNLIKELY (extraAlignment > 0) extraAlignment = ((instanceSize + extraAlignment - 1) & ~(extraAlignment - 1)) - extraAlignment; instance = malloc(PRE_IVARS_ALIGN + instanceSize + extraAlignment + extraSize); if OF_UNLIKELY (instance == nil) { alloc_failed_exception.isa = [OFAllocFailedException class]; @throw (id)&alloc_failed_exception; } ((struct pre_ivar*)instance)->retainCount = 1; ((struct pre_ivar*)instance)->firstMem = NULL; ((struct pre_ivar*)instance)->lastMem = NULL; #if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS) if OF_UNLIKELY (!of_spinlock_new( &((struct pre_ivar*)instance)->retainCountSpinlock)) { free(instance); @throw [OFInitializationFailedException exceptionWithClass: class]; } #endif instance = (OFObject*)((char*)instance + PRE_IVARS_ALIGN); memset(instance, 0, instanceSize); if (!objc_constructInstance(class, instance)) { free((char*)instance - PRE_IVARS_ALIGN); @throw [OFInitializationFailedException exceptionWithClass: class]; } if OF_UNLIKELY (extra != NULL) *extra = (char*)instance + instanceSize + extraAlignment; |
︙ | ︙ | |||
868 869 870 871 872 873 874 | } - (void*)allocMemoryWithSize: (size_t)size { void *pointer; struct pre_mem *preMem; | | | | | | | | | 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 | } - (void*)allocMemoryWithSize: (size_t)size { void *pointer; struct pre_mem *preMem; 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_IVARS->lastMem; preMem->next = NULL; if OF_LIKELY (PRE_IVARS->lastMem != NULL) PRE_IVARS->lastMem->next = 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 count: (size_t)count { |
︙ | ︙ | |||
933 934 935 936 937 938 939 | if OF_UNLIKELY (preMem != PRE_MEM(pointer)) { if OF_LIKELY (preMem->prev != NULL) preMem->prev->next = preMem; if OF_LIKELY (preMem->next != NULL) preMem->next->prev = preMem; | | | | | | 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 | if OF_UNLIKELY (preMem != PRE_MEM(pointer)) { if OF_LIKELY (preMem->prev != NULL) preMem->prev->next = preMem; if OF_LIKELY (preMem->next != NULL) preMem->next->prev = 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; } - (void*)resizeMemory: (void*)pointer size: (size_t)size |
︙ | ︙ | |||
977 978 979 980 981 982 983 | pointer: pointer]; 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; | | | | | | | | | | | | | | | | | | 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 | pointer: pointer]; 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_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)); } - (id)forwardingTargetForSelector: (SEL)selector { return nil; } - retain { #if defined(OF_ATOMIC_OPS) of_atomic_inc_32(&PRE_IVARS->retainCount); #elif defined(OF_THREADS) OF_ENSURE(of_spinlock_lock(&PRE_IVARS->retainCountSpinlock)); PRE_IVARS->retainCount++; OF_ENSURE(of_spinlock_unlock(&PRE_IVARS->retainCountSspinlock)); #else PRE_IVARS->retainCount++; #endif return self; } - (unsigned int)retainCount { assert(PRE_IVARS->retainCount >= 0); return PRE_IVARS->retainCount; } - (void)release { #if defined(OF_ATOMIC_OPS) if (of_atomic_dec_32(&PRE_IVARS->retainCount) <= 0) [self dealloc]; #elif defined(OF_THREADS) size_t c; 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_IVARS->retainCount == 0) [self dealloc]; #endif } - autorelease { return _objc_rootAutorelease(self); |
︙ | ︙ | |||
1055 1056 1057 1058 1059 1060 1061 | - (void)dealloc { struct pre_mem *iter; objc_destructInstance(self); | | | | 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 | - (void)dealloc { struct pre_mem *iter; objc_destructInstance(self); iter = PRE_IVARS->firstMem; while (iter != NULL) { struct pre_mem *next = iter->next; /* * We can use owner as a sentinel to prevent exploitation in * case there is a buffer underflow somewhere. */ if OF_UNLIKELY (iter->owner != self) abort(); free(iter); iter = next; } free((char*)self - PRE_IVARS_ALIGN); } /* Required to use properties with the Apple runtime */ - copyWithZone: (void*)zone { if OF_UNLIKELY (zone != NULL) @throw [OFNotImplementedException |
︙ | ︙ |
Modified src/OFString.h from [af8955aa05] to [0b6a858bc6].
︙ | ︙ | |||
191 192 193 194 195 196 197 | * @return A new autoreleased OFString */ + (instancetype)stringWithUnicodeString: (const of_unichar_t*)string byteOrder: (of_byte_order_t)byteOrder length: (size_t)length; /*! | | | | | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | * @return A new autoreleased OFString */ + (instancetype)stringWithUnicodeString: (const of_unichar_t*)string byteOrder: (of_byte_order_t)byteOrder length: (size_t)length; /*! * @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; /*! * @brief Creates a new OFString from a UTF-16 encoded string, assuming the * specified byte order if no BOM is found. * * @param string The UTF-16 string * @param byteOrder The byte order to assume if there is no BOM * @return A new autoreleased OFString */ + (instancetype)stringWithUTF16String: (const uint16_t*)string byteOrder: (of_byte_order_t)byteOrder; /*! * @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 */ + (instancetype)stringWithUTF16String: (const uint16_t*)string length: (size_t)length; |
︙ | ︙ |
Modified src/OFXMLParser.m from [9e2d46e499] to [c33143cf90].
︙ | ︙ | |||
58 59 60 61 62 63 64 | count: [tmp UTF8StringLength]]; objc_autoreleasePoolPop(pool); } } static OFString* transform_string(OFDataArray *cache, size_t cut, BOOL unescape, | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | count: [tmp UTF8StringLength]]; objc_autoreleasePoolPop(pool); } } static OFString* transform_string(OFDataArray *cache, size_t cut, BOOL unescape, id <OFStringXMLUnescapingDelegate> delegate) { char *cArray; size_t i, length; BOOL hasEntities = NO; OFMutableString *ret; cArray = [cache cArray]; |
︙ | ︙ |