ObjFW  Check-in [36872c7a25]

Overview
Comment:Fix memory wasting in OFBigDataArray.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 36872c7a2564e41af38afb8c74b7a0242e6d82b8b45be10b6eff1f83e2cf6de2
User & Date: js on 2012-03-16 17:14:30
Other Links: manifest | tags
Context
2012-03-16
17:32
OFXMLParser: Don't recreate "attributes" all the time. check-in: 4a080857a2 user: js tags: trunk
17:14
Fix memory wasting in OFBigDataArray. check-in: 36872c7a25 user: js tags: trunk
14:01
One malloc less when allocating a string. check-in: 3005748a9d user: js tags: trunk
Changes

Modified src/OFDataArray.m from [80fa284829] to [f620eb9fde].

536
537
538
539
540
541
542
543

544
545
546
547
548
549
550
551
536
537
538
539
540
541
542

543

544
545
546
547
548
549
550







-
+
-







		@throw [OFOutOfRangeException exceptionWithClass: isa];

	lastPageByte = of_pagesize - 1;
	newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;

	if (size != newSize)
		data = [self resizeMemory: data
				 toNItems: newSize
				   toSize: newSize];
				   ofSize: itemSize];

	memmove(data + (index + nItems) * itemSize, data + index * itemSize,
	    (count - index) * itemSize);
	memcpy(data + index * itemSize, cArray, nItems * itemSize);

	count += nItems;
	size = newSize;