ObjFW  Check-in [bf8a579f38]

Overview
Comment:OFCountedSet: More thorough range check.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bf8a579f38024a9a456f8a7fb111aefca1d788ecde32094653c8398a4d026e3b
User & Date: js on 2013-02-19 11:57:07
Other Links: manifest | tags
Context
2013-02-21
16:15
Add support for parsing BinaryPack. check-in: 12f091ddd6 user: js tags: trunk
2013-02-19
11:57
OFCountedSet: More thorough range check. check-in: bf8a579f38 user: js tags: trunk
2013-02-18
23:05
Make OFHash a protocol. check-in: 9b2d255a3d user: js tags: trunk
Changes

Modified src/OFCountedSet.m from [0dc9d61751] to [028e438698].

122
123
124
125
126
127
128
129
130
131
132
133


134
135
136
137
138
139
140
}

- init
{
	if (object_getClass(self) == [OFCountedSet class]) {
		@try {
			[self doesNotRecognizeSelector: _cmd];
			abort();
		} @catch (id e) {
			[self release];
			@throw e;
		}


	}

	return [super init];
}

- (size_t)countForObject: (id)object
{







<




>
>







122
123
124
125
126
127
128

129
130
131
132
133
134
135
136
137
138
139
140
141
}

- init
{
	if (object_getClass(self) == [OFCountedSet class]) {
		@try {
			[self doesNotRecognizeSelector: _cmd];

		} @catch (id e) {
			[self release];
			@throw e;
		}

		abort();
	}

	return [super init];
}

- (size_t)countForObject: (id)object
{

Modified src/OFCountedSet_hashtable.m from [1c8a9015a1] to [9994d542a0].

205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
}
#endif

- (void)addObject: (id)object
{
	size_t count = (size_t)(uintptr_t)[_mapTable valueForKey: object];

	if (SIZE_MAX - count < 1)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	[_mapTable setValue: (void*)(uintptr_t)(count + 1)
		     forKey: object];
}

- (void)removeObject: (id)object







|







205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
}
#endif

- (void)addObject: (id)object
{
	size_t count = (size_t)(uintptr_t)[_mapTable valueForKey: object];

	if (SIZE_MAX - count < 1 || UINTPTR_MAX - count < 1)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	[_mapTable setValue: (void*)(uintptr_t)(count + 1)
		     forKey: object];
}

- (void)removeObject: (id)object

Modified src/OFDictionary.h from [e10f379adb] to [e73cae8cf9].

220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
    (of_dictionary_enumeration_block_t)block;

/*!
 * @brief Creates a new dictionary, mapping each object using the specified
 *	  block.
 *
 * @param block A block which maps an object for each object
 * @return A new, autorelease OFDictionary
 */
- (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block;

/*!
 * @brief Creates a new dictionary, only containing the objects for which the
 *	  block returns YES.
 *
 * @param block A block which determines if the object should be in the new
 *		dictionary
 * @return A new, autoreleased OFDictionary
 */
- (OFDictionary*)filteredDictionaryUsingBlock:
    (of_dictionary_filter_block_t)block;
#endif
@end

#import "OFMutableDictionary.h"

#ifndef NSINTEGER_DEFINED
/* Required for dictionary literals to work */
@compatibility_alias NSDictionary OFDictionary;
#endif







|









|












220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
    (of_dictionary_enumeration_block_t)block;

/*!
 * @brief Creates a new dictionary, mapping each object using the specified
 *	  block.
 *
 * @param block A block which maps an object for each object
 * @return A new autoreleased OFDictionary
 */
- (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block;

/*!
 * @brief Creates a new dictionary, only containing the objects for which the
 *	  block returns YES.
 *
 * @param block A block which determines if the object should be in the new
 *		dictionary
 * @return A new autoreleased OFDictionary
 */
- (OFDictionary*)filteredDictionaryUsingBlock:
    (of_dictionary_filter_block_t)block;
#endif
@end

#import "OFMutableDictionary.h"

#ifndef NSINTEGER_DEFINED
/* Required for dictionary literals to work */
@compatibility_alias NSDictionary OFDictionary;
#endif