606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
|
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
|
-
-
+
+
-
+
-
+
-
+
-
+
|
PRE_IVAR->lastMem->next = preMem;
PRE_IVAR->lastMem = preMem;
return (char*)pointer + PRE_MEM_ALIGN;
}
- (void*)allocMemoryWithItemSize: (size_t)itemSize
count: (size_t)count
- (void*)allocMemoryWithSize: (size_t)size
count: (size_t)count
{
if (itemSize == 0 || count == 0)
if (size == 0 || count == 0)
return NULL;
if (count > SIZE_MAX / itemSize)
if (count > SIZE_MAX / size)
@throw [OFOutOfRangeException exceptionWithClass: isa];
return [self allocMemoryWithSize: itemSize * count];
return [self allocMemoryWithSize: size * count];
}
- (void*)resizeMemory: (void*)pointer
toSize: (size_t)size
size: (size_t)size
{
void *new;
struct pre_mem *preMem;
if (pointer == NULL)
return [self allocMemoryWithSize: size];
|
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
itemSize: (size_t)itemSize
size: (size_t)size
count: (size_t)count
{
if (pointer == NULL)
return [self allocMemoryWithItemSize: itemSize
count: count];
return [self allocMemoryWithSize: size
count: count];
if (itemSize == 0 || count == 0) {
if (size == 0 || count == 0) {
[self freeMemory: pointer];
return NULL;
}
if (count > SIZE_MAX / itemSize)
if (count > SIZE_MAX / size)
@throw [OFOutOfRangeException exceptionWithClass: isa];
return [self resizeMemory: pointer
toSize: itemSize * count];
size: size * 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
|
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
|
-
-
+
+
-
+
-
+
|
*/
+ (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
+ (void*)allocMemoryWithItemSize: (size_t)itemSize
count: (size_t)count
+ (void*)allocMemoryWithSize: (size_t)size
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
+ (void*)resizeMemory: (void*)pointer
toSize: (size_t)size
size: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
+ (void*)resizeMemory: (void*)pointer
itemSize: (size_t)itemSize
size: (size_t)size
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
+ (void)freeMemory: (void*)pointer
|