ObjFW  Diff

Differences From Artifact [e193cfb1d7]:

  • File src/OFDictionary_hashtable.m — part of check-in [e1e7ffa903] at 2011-09-22 23:25:42 on branch trunk — Exceptions are now autoreleased.

    This is safe as an "exception loop" can't happen, since if allocating
    an exception fails, it throws an OFAllocFailedException which is
    preallocated and can always be thrown.

    So, the worst case would be that an autorelease of an exception fails,
    triggering an OFOutOfMemoryException for which there is no memory,
    resulting in an OFAllocFailedException to be thrown. (user: js, size: 17408) [annotate] [blame] [check-ins using]

To Artifact [86b064ec63]:


131
132
133
134
135
136
137


138
139
140
141
142
143
144

		count = [dictionary count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		for (newSize = 1; newSize < count; newSize <<= 1);



		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryForNItems: newSize
					   ofSize: sizeof(*data)];








>
>







131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

		count = [dictionary count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		for (newSize = 1; newSize < count; newSize <<= 1);
		if (count * 4 / newSize >= 3)
			newSize <<= 1;

		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryForNItems: newSize
					   ofSize: sizeof(*data)];

243
244
245
246
247
248
249


250
251
252
253
254
255
256
		objectsCArray = [objects cArray];
		count = [keys count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		for (newSize = 1; newSize < count; newSize <<= 1);



		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryForNItems: newSize
					   ofSize: sizeof(*data)];








>
>







245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
		objectsCArray = [objects cArray];
		count = [keys count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		for (newSize = 1; newSize < count; newSize <<= 1);
		if (count * 4 / newSize >= 3)
			newSize <<= 1;

		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryForNItems: newSize
					   ofSize: sizeof(*data)];

363
364
365
366
367
368
369


370
371
372
373
374
375
376
		for (; va_arg(argumentsCopy, id) != nil; count++);
		count >>= 1;

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		for (newSize = 1; newSize < count; newSize <<= 1);



		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryForNItems: newSize
					   ofSize: sizeof(*data)];








>
>







367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
		for (; va_arg(argumentsCopy, id) != nil; count++);
		count >>= 1;

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		for (newSize = 1; newSize < count; newSize <<= 1);
		if (count * 4 / newSize >= 3)
			newSize <<= 1;

		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryForNItems: newSize
					   ofSize: sizeof(*data)];