Sorts an array of pointers to 'sha256_midstate's in place in memcmp order. * If malloc fails, returns false. * Otherwise, returns true. * * The time complexity of rsort is O('len'). * * We are sorting in memcmp order, which is the lexicographical order of the object representation, i.e. the order that one * gets when casting 'sha256_midstate' to a 'unsigned char[]'. This representation is i
| 247 | * Precondition: For all 0 <= i < len, NULL != a[i]; |
| 248 | */ |
| 249 | bool simplicity_rsort(const sha256_midstate** a, uint_fast32_t len) { |
| 250 | uint32_t *stack = simplicity_malloc(((CHAR_COUNT - 1)*(sizeof((*a)->s)) + 1) * sizeof(uint32_t)); |
| 251 | if (!stack) return false; |
| 252 | rsort_ex(a, len, NULL, stack); |
| 253 | simplicity_free(stack); |
| 254 | return true; |
| 255 | } |
| 256 | |
| 257 | /* Searches for duplicates in an array of 'sha256_midstate's. |
| 258 | * If malloc fails, returns -1. |
no test coverage detected