Overview
Comment: | OFData: Change no copy handling
OFMutableData supports no copy now by just copying anyway and freeing if |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6cf7d6c33ed66726e13c97ba8f9c8dc9 |
User & Date: | js on 2017-11-26 14:29:40 |
Other Links: | manifest | tags |
Context
2017-12-23
| ||
18:21 | Disable compiler TLS on iOS 9 simulator check-in: d654e38e7e user: js tags: trunk | |
2017-11-26
| ||
14:29 | OFData: Change no copy handling check-in: 6cf7d6c33e user: js tags: trunk | |
2017-11-22
| ||
01:05 | OF_APPLICATION_DELEGATE(): Improve type checking check-in: 54b38752bb user: js tags: trunk | |
Changes
Modified src/OFData.h from [bda35b67de] to [507fa08959].
︙ | ︙ | |||
110 111 112 113 114 115 116 | * * @param items The items to store in the OFData * @param count The number of items * @param freeWhenDone Whether to free the pointer when it is no longer needed * by the OFData * @return A new autoreleased OFData */ | | | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | * * @param items The items to store in the OFData * @param count The number of items * @param freeWhenDone Whether to free the pointer when it is no longer needed * by the OFData * @return A new autoreleased OFData */ + (instancetype)dataWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone; /*! * @brief Creates a new OFData with the specified `count` items of the * specified size by taking ownership of the specified items pointer. * * @param items The items to store in the OFData * @param itemSize The item size of a single item in bytes * @param count The number of items * @param freeWhenDone Whether to free the pointer when it is no longer needed * by the OFData * @return A new autoreleased OFData */ + (instancetype)dataWithItemsNoCopy: (void *)items itemSize: (size_t)itemSize count: (size_t)count freeWhenDone: (bool)freeWhenDone; #ifdef OF_HAVE_FILES /*! * @brief Creates a new OFData with an item size of 1, containing the data of |
︙ | ︙ | |||
207 208 209 210 211 212 213 | * * @param items The items to store in the OFData * @param count The number of items * @param freeWhenDone Whether to free the pointer when it is no longer needed * by the OFData * @return An initialized OFData */ | | | | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | * * @param items The items to store in the OFData * @param count The number of items * @param freeWhenDone Whether to free the pointer when it is no longer needed * by the OFData * @return An initialized OFData */ - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone; /*! * @brief Initializes an already allocated OFData with the specified `count` * items of the specified size by taking ownership of the specified * items pointer. * * @param items The items to store in the OFData * @param itemSize The item size of a single item in bytes * @param count The number of items * @param freeWhenDone Whether to free the pointer when it is no longer needed * by the OFData * @return An initialized OFData */ - (instancetype)initWithItemsNoCopy: (void *)items itemSize: (size_t)itemSize count: (size_t)count freeWhenDone: (bool)freeWhenDone; #ifdef OF_HAVE_FILES /*! * @brief Initializes an already allocated OFData with an item size of 1, |
︙ | ︙ |
Modified src/OFData.m from [744ee14c6a] to [d98f273881].
︙ | ︙ | |||
65 66 67 68 69 70 71 | count: (size_t)count { return [[[self alloc] initWithItems: items itemSize: itemSize count: count] autorelease]; } | | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | count: (size_t)count { return [[[self alloc] initWithItems: items itemSize: itemSize count: count] autorelease]; } + (instancetype)dataWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone { return [[[self alloc] initWithItemsNoCopy: items count: count freeWhenDone: freeWhenDone] autorelease]; } + (instancetype)dataWithItemsNoCopy: (void *)items itemSize: (size_t)itemSize count: (size_t)count freeWhenDone: (bool)freeWhenDone { return [[[self alloc] initWithItemsNoCopy: items itemSize: itemSize count: count |
︙ | ︙ | |||
152 153 154 155 156 157 158 | [self release]; @throw e; } return self; } | | | | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | [self release]; @throw e; } return self; } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone { return [self initWithItemsNoCopy: items itemSize: 1 count: count freeWhenDone: freeWhenDone]; } - (instancetype)initWithItemsNoCopy: (void *)items itemSize: (size_t)itemSize count: (size_t)count freeWhenDone: (bool)freeWhenDone { self = [super init]; @try { |
︙ | ︙ |
Modified src/OFMutableData.h from [68a8c877d6] to [8d5b632b3f].
︙ | ︙ | |||
63 64 65 66 67 68 69 | * @param itemSize The size of a single element in the OFMutableData * @param capacity The initial capacity for the OFMutableData * @return A new autoreleased OFMutableData */ + (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity; | < < < < < < < < | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | * @param itemSize The size of a single element in the OFMutableData * @param capacity The initial capacity for the OFMutableData * @return A new autoreleased OFMutableData */ + (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity; /*! * @brief Initializes an already allocated OFMutableData with an item size of 1. * * @return An initialized OFMutableData */ - (instancetype)init; |
︙ | ︙ | |||
109 110 111 112 113 114 115 | * @param itemSize The size of a single element in the OFMutableData * @param capacity The initial capacity for the OFMutableData * @return An initialized OFMutableData */ - (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity; | < < < < < < < < | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | * @param itemSize The size of a single element in the OFMutableData * @param capacity The initial capacity for the OFMutableData * @return An initialized OFMutableData */ - (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity; /*! * @brief Adds an item to the OFMutableData. * * @param item A pointer to an arbitrary item */ - (void)addItem: (const void *)item; |
︙ | ︙ |
Modified src/OFMutableData.m from [c971350bab] to [d12ca7c473].
︙ | ︙ | |||
47 48 49 50 51 52 53 | + (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity { return [[[self alloc] initWithItemSize: itemSize capacity: capacity] autorelease]; } | < < < < < < < < < < < < < < < | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | + (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity { return [[[self alloc] initWithItemSize: itemSize capacity: capacity] autorelease]; } - (instancetype)init { self = [super of_init]; _itemSize = 1; return self; |
︙ | ︙ | |||
129 130 131 132 133 134 135 | count: count]; _capacity = _count; return self; } | | > > | > > | > | > | > > > | > > > > | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | count: count]; _capacity = _count; return self; } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone { self = [self initWithItems: items count: count]; if (freeWhenDone) free(items); return self; } - (instancetype)initWithItemsNoCopy: (void *)items itemSize: (size_t)itemSize count: (size_t)count freeWhenDone: (bool)freeWhenDone { self = [self initWithItems: items itemSize: itemSize count: count]; if (freeWhenDone) free(items); return self; } - (instancetype)initWithStringRepresentation: (OFString *)string { self = [super initWithStringRepresentation: string]; _capacity = _count; |
︙ | ︙ |