@@ -28,12 +28,10 @@ #endif static void init(void) { - uint16_t i; - empty_level2 = malloc(sizeof(struct objc_dtable_level2)); if (empty_level2 == NULL) OBJC_ERROR("Not enough memory to allocate dtable!"); #ifdef OF_SELUID24 @@ -41,25 +39,24 @@ if (empty_level3 == NULL) OBJC_ERROR("Not enough memory to allocate dtable!"); #endif #ifdef OF_SELUID24 - for (i = 0; i < 256; i++) { + for (uint_fast16_t i = 0; i < 256; i++) { empty_level2->buckets[i] = empty_level3; empty_level3->buckets[i] = (IMP)0; } #else - for (i = 0; i < 256; i++) + for (uint_fast16_t i = 0; i < 256; i++) empty_level2->buckets[i] = (IMP)0; #endif } struct objc_dtable* objc_dtable_new(void) { struct objc_dtable *dtable; - uint16_t i; #ifdef OF_SELUID24 if (empty_level2 == NULL || empty_level3 == NULL) init(); #else @@ -68,36 +65,31 @@ #endif if ((dtable = malloc(sizeof(struct objc_dtable))) == NULL) OBJC_ERROR("Not enough memory to allocate dtable!"); - for (i = 0; i < 256; i++) + for (uint_fast16_t i = 0; i < 256; i++) dtable->buckets[i] = empty_level2; return dtable; } void objc_dtable_copy(struct objc_dtable *dst, struct objc_dtable *src) { - uint16_t i, j; -#ifdef OF_SELUID24 - uint16_t k; -#endif - uint32_t idx; - - for (i = 0; i < 256; i++) { + for (uint_fast16_t i = 0; i < 256; i++) { if (src->buckets[i] == empty_level2) continue; #ifdef OF_SELUID24 - for (j = 0; j < 256; j++) { + for (uint_fast16_t j = 0; j < 256; j++) { if (src->buckets[i]->buckets[j] == empty_level3) continue; - for (k = 0; k < 256; k++) { + for (uint_fast16_t k = 0; k < 256; k++) { IMP obj; + uint32_t idx; obj = src->buckets[i]->buckets[j]->buckets[k]; if (obj == (IMP)0) continue; @@ -106,14 +98,13 @@ (((uint32_t)i << 16) | (j << 8) | k); objc_dtable_set(dst, idx, obj); } } #else - for (j = 0; j < 256; j++) { - IMP obj; - - obj = src->buckets[i]->buckets[j]; + for (uint_fast16_t j = 0; j < 256; j++) { + IMP obj = src->buckets[i]->buckets[j]; + uint32_t idx; if (obj == (IMP)0) continue; idx = (uint32_t)((i << 8) | j); @@ -134,19 +125,17 @@ uint8_t i = idx >> 8; uint8_t j = idx; #endif if (dtable->buckets[i] == empty_level2) { - struct objc_dtable_level2 *level2; - uint16_t l; - - level2 = malloc(sizeof(struct objc_dtable_level2)); + struct objc_dtable_level2 *level2 = + malloc(sizeof(struct objc_dtable_level2)); if (level2 == NULL) OBJC_ERROR("Not enough memory to insert into dtable!"); - for (l = 0; l < 256; l++) + for (uint_fast16_t l = 0; l < 256; l++) #ifdef OF_SELUID24 level2->buckets[l] = empty_level3; #else level2->buckets[l] = (IMP)0; #endif @@ -154,19 +143,17 @@ dtable->buckets[i] = level2; } #ifdef OF_SELUID24 if (dtable->buckets[i]->buckets[j] == empty_level3) { - struct objc_dtable_level3 *level3; - uint16_t l; - - level3 = malloc(sizeof(struct objc_dtable_level3)); + struct objc_dtable_level3 *level3 = + malloc(sizeof(struct objc_dtable_level3)); if (level3 == NULL) OBJC_ERROR("Not enough memory to insert into dtable!"); - for (l = 0; l < 256; l++) + for (uint_fast16_t l = 0; l < 256; l++) level3->buckets[l] = (IMP)0; dtable->buckets[i]->buckets[j] = level3; } @@ -177,21 +164,16 @@ } void objc_dtable_free(struct objc_dtable *dtable) { - uint16_t i; -#ifdef OF_SELUID24 - uint16_t j; -#endif - - for (i = 0; i < 256; i++) { + for (uint_fast16_t i = 0; i < 256; i++) { if (dtable->buckets[i] == empty_level2) continue; #ifdef OF_SELUID24 - for (j = 0; j < 256; j++) + for (uint_fast16_t j = 0; j < 256; j++) if (dtable->buckets[i]->buckets[j] != empty_level3) free(dtable->buckets[i]->buckets[j]); #endif free(dtable->buckets[i]);