@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2021 Jonathan Schleifer + * Copyright (c) 2008-2022 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -28,15 +28,15 @@ static void init(void) { if ((emptyLevel2 = malloc(sizeof(*emptyLevel2))) == NULL) - OBJC_ERROR("Not enough memory to allocate dtable!"); + OBJC_ERROR("Not enough memory to allocate dispatch table!"); #ifdef OF_SELUID24 if ((emptyLevel3 = malloc(sizeof(*emptyLevel3))) == NULL) - OBJC_ERROR("Not enough memory to allocate dtable!"); + OBJC_ERROR("Not enough memory to allocate dispatch table!"); #endif #ifdef OF_SELUID24 for (uint_fast16_t i = 0; i < 256; i++) { emptyLevel2->buckets[i] = emptyLevel3; @@ -49,27 +49,27 @@ } struct objc_dtable * objc_dtable_new(void) { - struct objc_dtable *DTable; + struct objc_dtable *dTable; #ifdef OF_SELUID24 if (emptyLevel2 == NULL || emptyLevel3 == NULL) init(); #else if (emptyLevel2 == NULL) init(); #endif - if ((DTable = malloc(sizeof(*DTable))) == NULL) - OBJC_ERROR("Not enough memory to allocate dtable!"); + if ((dTable = malloc(sizeof(*dTable))) == NULL) + OBJC_ERROR("Not enough memory to allocate dispatch table!"); for (uint_fast16_t i = 0; i < 256; i++) - DTable->buckets[i] = emptyLevel2; + dTable->buckets[i] = emptyLevel2; - return DTable; + return dTable; } void objc_dtable_copy(struct objc_dtable *dest, struct objc_dtable *src) { @@ -111,11 +111,11 @@ #endif } } void -objc_dtable_set(struct objc_dtable *DTable, uint32_t idx, IMP implementation) +objc_dtable_set(struct objc_dtable *dTable, uint32_t idx, IMP implementation) { #ifdef OF_SELUID24 uint8_t i = idx >> 16; uint8_t j = idx >> 8; uint8_t k = idx; @@ -122,62 +122,64 @@ #else uint8_t i = idx >> 8; uint8_t j = idx; #endif - if (DTable->buckets[i] == emptyLevel2) { + if (dTable->buckets[i] == emptyLevel2) { struct objc_dtable_level2 *level2 = malloc(sizeof(*level2)); if (level2 == NULL) - OBJC_ERROR("Not enough memory to insert into dtable!"); + OBJC_ERROR("Not enough memory to insert into " + "dispatch table!"); for (uint_fast16_t l = 0; l < 256; l++) #ifdef OF_SELUID24 level2->buckets[l] = emptyLevel3; #else level2->buckets[l] = (IMP)0; #endif - DTable->buckets[i] = level2; + dTable->buckets[i] = level2; } #ifdef OF_SELUID24 - if (DTable->buckets[i]->buckets[j] == emptyLevel3) { + if (dTable->buckets[i]->buckets[j] == emptyLevel3) { struct objc_dtable_level3 *level3 = malloc(sizeof(*level3)); if (level3 == NULL) - OBJC_ERROR("Not enough memory to insert into dtable!"); + OBJC_ERROR("Not enough memory to insert into " + "dispatch table!"); for (uint_fast16_t l = 0; l < 256; l++) level3->buckets[l] = (IMP)0; - DTable->buckets[i]->buckets[j] = level3; + dTable->buckets[i]->buckets[j] = level3; } - DTable->buckets[i]->buckets[j]->buckets[k] = implementation; + dTable->buckets[i]->buckets[j]->buckets[k] = implementation; #else - DTable->buckets[i]->buckets[j] = implementation; + dTable->buckets[i]->buckets[j] = implementation; #endif } void -objc_dtable_free(struct objc_dtable *DTable) +objc_dtable_free(struct objc_dtable *dTable) { for (uint_fast16_t i = 0; i < 256; i++) { - if (DTable->buckets[i] == emptyLevel2) + if (dTable->buckets[i] == emptyLevel2) continue; #ifdef OF_SELUID24 for (uint_fast16_t j = 0; j < 256; j++) - if (DTable->buckets[i]->buckets[j] != emptyLevel3) - free(DTable->buckets[i]->buckets[j]); + if (dTable->buckets[i]->buckets[j] != emptyLevel3) + free(dTable->buckets[i]->buckets[j]); #endif - free(DTable->buckets[i]); + free(dTable->buckets[i]); } - free(DTable); + free(dTable); } void objc_dtable_cleanup(void) {