| 41 | } |
| 42 | |
| 43 | void * get_happycoins(void * arg) { |
| 44 | int attempts = *(int *)arg; // <1> |
| 45 | int limit = attempts/10000; |
| 46 | uint32_t seed = time(NULL); |
| 47 | uint64_t * nums = malloc(limit * sizeof(uint64_t)); |
| 48 | struct happy_result * result = malloc(sizeof(struct happy_result)); |
| 49 | result->nums = nums; |
| 50 | result->count = 0; |
| 51 | for (int i = 1; i < attempts; i++) { |
| 52 | if (result->count == limit) { |
| 53 | break; |
| 54 | } |
| 55 | uint64_t random_num = random64(&seed); |
| 56 | if (is_happycoin(random_num)) { |
| 57 | result->nums[result->count++] = random_num; |
| 58 | } |
| 59 | } |
| 60 | return (void *)result; |
| 61 | } |
| 62 | |
| 63 | #define THREAD_COUNT 4 |
| 64 |
nothing calls this directly
no test coverage detected