ObjFW  Diff

Differences From Artifact [a14dce520b]:

  • File src/OFObject.m — part of check-in [042a74a6e6] at 2009-05-03 14:48:41 on branch trunk — Don't throw an OFNoMemException in - freeMem:. It won't help anyway.

    If there's not even enough memory to make the list of memchunks
    smaller, there can't be much done anyway. The only way is to ignore
    it and hope the whole object gets free'd soon, as the memchunk will
    be free'd then as well.

    Additionally, the OFOutOfRangeException was replaced by an assert. It
    should never overflow here as we're making it smaller. And a size of 0
    can't happen as we already found the memchunk before. (user: js, size: 8105) [annotate] [blame] [check-ins using]

To Artifact [ed4919e346]:


289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
					     andPointer: ptr];
}

- (void*)resizeMem: (void*)ptr
	  toNItems: (size_t)nitems
	  withSize: (size_t)size
{
	size_t memsize;

	if (ptr == NULL)
		return [self allocNItems: nitems
				withSize: size];

	if (nitems == 0 || size == 0) {
		[self freeMem: ptr];
		return NULL;
	}

	if (nitems > SIZE_MAX / size)
		@throw [OFOutOfRangeException newWithClass: isa];

	memsize = nitems * size;
	return [self resizeMem: ptr
			toSize: memsize];
}

- freeMem: (void*)ptr;
{
	void **iter, *last, **memchunks;
	size_t i, memchunks_size;








<
<












<

|







289
290
291
292
293
294
295


296
297
298
299
300
301
302
303
304
305
306
307

308
309
310
311
312
313
314
315
316
					     andPointer: ptr];
}

- (void*)resizeMem: (void*)ptr
	  toNItems: (size_t)nitems
	  withSize: (size_t)size
{


	if (ptr == NULL)
		return [self allocNItems: nitems
				withSize: size];

	if (nitems == 0 || size == 0) {
		[self freeMem: ptr];
		return NULL;
	}

	if (nitems > SIZE_MAX / size)
		@throw [OFOutOfRangeException newWithClass: isa];


	return [self resizeMem: ptr
			toSize: nitems * size];
}

- freeMem: (void*)ptr;
{
	void **iter, *last, **memchunks;
	size_t i, memchunks_size;