Given an array of midstate pointers, * count the frequencies of the values of the 'j'th character of each midstate's internal representation. * Returns 'true' if the 'j'th character of every entry is the same, otherwise returns 'false'. * * The time complexity of 'freq' is O('len'). * * Precondition: uint32_t result[CHAR_COUNT]; * for all 0 <= i < len, NULL != a[i]; *
| 34 | * j < sizeof((*a)->s) |
| 35 | */ |
| 36 | static bool freq(uint32_t* result, const sha256_midstate * const * a, uint_fast32_t len, unsigned int j) { |
| 37 | memset(result, 0, CHAR_COUNT * sizeof(uint32_t)); |
| 38 | |
| 39 | if (0 == len) return true; |
| 40 | |
| 41 | for (size_t i = 0; i < len - 1; ++i) { |
| 42 | result[readIndex(a[i],j)]++; |
| 43 | } |
| 44 | |
| 45 | /* Check the final iteration to see if the frequency is equal to 'len'. */ |
| 46 | return len == ++result[readIndex(a[len-1],j)]; |
| 47 | } |
| 48 | |
| 49 | /* Given an array of bucket sizes, and an initial value 'bucketEdge[0]', |
| 50 | * add subsequent bucket edges of the given bucket sizes. |