ObjFW  Diff

Differences From Artifact [26d577e585]:

To Artifact [71be745647]:


606
607
608
609
610
611
612
613
614


615
616

617
618
619

620
621
622

623
624
625
626
627
628
629
606
607
608
609
610
611
612


613
614
615

616
617
618

619
620
621

622
623
624
625
626
627
628
629







-
-
+
+

-
+


-
+


-
+







		PRE_IVAR->lastMem->next = preMem;

	PRE_IVAR->lastMem = preMem;

	return (char*)pointer + PRE_MEM_ALIGN;
}

- (void*)allocMemoryForNItems: (size_t)nItems
		       ofSize: (size_t)size
- (void*)allocMemoryWithItemSize: (size_t)itemSize
			   count: (size_t)count
{
	if (nItems == 0 || size == 0)
	if (itemSize == 0 || count == 0)
		return NULL;

	if (nItems > SIZE_MAX / size)
	if (count > SIZE_MAX / itemSize)
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return [self allocMemoryWithSize: nItems * size];
	return [self allocMemoryWithSize: itemSize * count];
}

- (void*)resizeMemory: (void*)pointer
	       toSize: (size_t)size
{
	void *new;
	struct pre_mem *preMem;
658
659
660
661
662
663
664
665
666


667
668
669
670


671
672

673
674
675
676
677

678
679
680
681

682
683
684
685
686
687
688
658
659
660
661
662
663
664


665
666
667
668


669
670
671

672
673
674
675
676

677
678
679
680

681
682
683
684
685
686
687
688







-
-
+
+


-
-
+
+

-
+




-
+



-
+







			PRE_IVAR->lastMem = preMem;
	}

	return (char*)new + PRE_MEM_ALIGN;
}

- (void*)resizeMemory: (void*)pointer
	     toNItems: (size_t)nItems
	       ofSize: (size_t)size
	     itemSize: (size_t)itemSize
		count: (size_t)count
{
	if (pointer == NULL)
		return [self allocMemoryForNItems: nItems
					   ofSize: size];
		return [self allocMemoryWithItemSize: itemSize
					       count: count];

	if (nItems == 0 || size == 0) {
	if (itemSize == 0 || count == 0) {
		[self freeMemory: pointer];
		return NULL;
	}

	if (nItems > SIZE_MAX / size)
	if (count > SIZE_MAX / itemSize)
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return [self resizeMemory: pointer
			   toSize: nItems * size];
			   toSize: itemSize * count];
}

- (void)freeMemory: (void*)pointer
{
	if (pointer == NULL)
		return;

835
836
837
838
839
840
841
842
843


844
845
846
847
848
849
850
851
852
853
854
855
856
857
858


859
860
861
862
863
864
865
835
836
837
838
839
840
841


842
843
844
845
846
847
848
849
850
851
852
853
854
855
856


857
858
859
860
861
862
863
864
865







-
-
+
+













-
-
+
+







 */
+ (void*)allocMemoryWithSize: (size_t)size
{
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ (void*)allocMemoryForNItems: (size_t)nItems
		       ofSize: (size_t)size
+ (void*)allocMemoryWithItemSize: (size_t)itemSize
			   count: (size_t)count
{
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ (void*)resizeMemory: (void*)pointer
	       toSize: (size_t)size
{
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ (void*)resizeMemory: (void*)pointer
	     toNItems: (size_t)nItems
	      ofSize: (size_t)size
	     itemSize: (size_t)itemSize
		count: (size_t)count
{
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ (void)freeMemory: (void*)pointer
{