︙ | | | ︙ | |
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
- (uint32_t)hash
{
/* Classes containing data should reimplement this! */
return (uint32_t)(uintptr_t)self;
}
- addMemoryToPool: (void*)ptr
{
void **memchunks;
size_t memchunks_size;
memchunks_size = PRE_IVAR->memchunks_size + 1;
if (SIZE_MAX - PRE_IVAR->memchunks_size < 1 ||
memchunks_size > SIZE_MAX / sizeof(void*))
@throw [OFOutOfRangeException newWithClass: isa];
if ((memchunks = realloc(PRE_IVAR->memchunks,
memchunks_size * sizeof(void*))) == NULL)
@throw [OFOutOfMemoryException newWithClass: isa
size: memchunks_size];
PRE_IVAR->memchunks = memchunks;
PRE_IVAR->memchunks[PRE_IVAR->memchunks_size] = ptr;
PRE_IVAR->memchunks_size = memchunks_size;
return self;
}
- (void*)allocMemoryWithSize: (size_t)size
{
void *ptr, **memchunks;
size_t memchunks_size;
|
|
<
<
|
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
|
- (uint32_t)hash
{
/* Classes containing data should reimplement this! */
return (uint32_t)(uintptr_t)self;
}
- (void)addMemoryToPool: (void*)ptr
{
void **memchunks;
size_t memchunks_size;
memchunks_size = PRE_IVAR->memchunks_size + 1;
if (SIZE_MAX - PRE_IVAR->memchunks_size < 1 ||
memchunks_size > SIZE_MAX / sizeof(void*))
@throw [OFOutOfRangeException newWithClass: isa];
if ((memchunks = realloc(PRE_IVAR->memchunks,
memchunks_size * sizeof(void*))) == NULL)
@throw [OFOutOfMemoryException newWithClass: isa
size: memchunks_size];
PRE_IVAR->memchunks = memchunks;
PRE_IVAR->memchunks[PRE_IVAR->memchunks_size] = ptr;
PRE_IVAR->memchunks_size = memchunks_size;
}
- (void*)allocMemoryWithSize: (size_t)size
{
void *ptr, **memchunks;
size_t memchunks_size;
|
︙ | | | ︙ | |
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
|
if (nitems > SIZE_MAX / size)
@throw [OFOutOfRangeException newWithClass: isa];
return [self resizeMemory: ptr
toSize: nitems * size];
}
- freeMemory: (void*)ptr;
{
void **iter, *last, **memchunks;
size_t i, memchunks_size;
if (ptr == NULL)
return self;
iter = PRE_IVAR->memchunks + PRE_IVAR->memchunks_size;
i = PRE_IVAR->memchunks_size;
while (iter-- > PRE_IVAR->memchunks) {
i--;
|
|
|
|
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
|
if (nitems > SIZE_MAX / size)
@throw [OFOutOfRangeException newWithClass: isa];
return [self resizeMemory: ptr
toSize: nitems * size];
}
- (void)freeMemory: (void*)ptr;
{
void **iter, *last, **memchunks;
size_t i, memchunks_size;
if (ptr == NULL)
return;
iter = PRE_IVAR->memchunks + PRE_IVAR->memchunks_size;
i = PRE_IVAR->memchunks_size;
while (iter-- > PRE_IVAR->memchunks) {
i--;
|
︙ | | | ︙ | |
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
if (OF_UNLIKELY(memchunks_size == 0)) {
free(ptr);
free(PRE_IVAR->memchunks);
PRE_IVAR->memchunks = NULL;
PRE_IVAR->memchunks_size = 0;
return self;
}
free(ptr);
PRE_IVAR->memchunks[i] = last;
PRE_IVAR->memchunks_size = memchunks_size;
if (OF_UNLIKELY((memchunks = realloc(
PRE_IVAR->memchunks, memchunks_size *
sizeof(void*))) == NULL))
return self;
PRE_IVAR->memchunks = memchunks;
return self;
}
}
@throw [OFMemoryNotPartOfObjectException newWithClass: isa
pointer: ptr];
}
|
|
|
|
|
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
|
if (OF_UNLIKELY(memchunks_size == 0)) {
free(ptr);
free(PRE_IVAR->memchunks);
PRE_IVAR->memchunks = NULL;
PRE_IVAR->memchunks_size = 0;
return;
}
free(ptr);
PRE_IVAR->memchunks[i] = last;
PRE_IVAR->memchunks_size = memchunks_size;
if (OF_UNLIKELY((memchunks = realloc(
PRE_IVAR->memchunks, memchunks_size *
sizeof(void*))) == NULL))
return;
PRE_IVAR->memchunks = memchunks;
return;
}
}
@throw [OFMemoryNotPartOfObjectException newWithClass: isa
pointer: ptr];
}
|
︙ | | | ︙ | |
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
|
return [(id)self mutableCopy];
}
/*
* Those are needed as the root class is the superclass of the root class's
* metaclass and thus instance methods can be sent to class objects as well.
*/
+ addMemoryToPool: (void*)ptr
{
@throw [OFNotImplementedException newWithClass: self
selector: _cmd];
}
+ (void*)allocMemoryWithSize: (size_t)size
{
|
|
|
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
|
return [(id)self mutableCopy];
}
/*
* Those are needed as the root class is the superclass of the root class's
* metaclass and thus instance methods can be sent to class objects as well.
*/
+ (void)addMemoryToPool: (void*)ptr
{
@throw [OFNotImplementedException newWithClass: self
selector: _cmd];
}
+ (void*)allocMemoryWithSize: (size_t)size
{
|
︙ | | | ︙ | |
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
|
toNItems: (size_t)nitems
withSize: (size_t)size
{
@throw [OFNotImplementedException newWithClass: self
selector: _cmd];
}
+ freeMemory: (void*)ptr
{
@throw [OFNotImplementedException newWithClass: self
selector: _cmd];
}
+ retain
{
|
|
|
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
|
toNItems: (size_t)nitems
withSize: (size_t)size
{
@throw [OFNotImplementedException newWithClass: self
selector: _cmd];
}
+ (void)freeMemory: (void*)ptr
{
@throw [OFNotImplementedException newWithClass: self
selector: _cmd];
}
+ retain
{
|
︙ | | | ︙ | |