diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2017-01-08 01:04:34 -0800 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2017-01-08 01:04:34 -0800 |
commit | 66d2c520910c57ae0d4d3afbb8fea74b862e3875 (patch) | |
tree | cff58ec4c2297b7752d176e93ac88cefec3006df /src/choices.c | |
parent | 47dee6d7b8c66eead65e1f771bdaa2b924e305a8 (diff) |
Store choices on job struct
Diffstat (limited to 'src/choices.c')
-rw-r--r-- | src/choices.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/choices.c b/src/choices.c index eb19bed..619e339 100644 --- a/src/choices.c +++ b/src/choices.c @@ -139,12 +139,12 @@ size_t choices_available(choices_t *c) { } struct search_job { + choices_t *choices; const char *search; }; struct worker { pthread_t thread_id; - choices_t *choices; struct search_job *job; size_t worker_num; struct scored_result *results; @@ -154,7 +154,7 @@ struct worker { static void *choices_search_worker(void *data) { struct worker *w = (struct worker *)data; struct search_job *job = w->job; - const choices_t *c = w->choices; + const choices_t *c = job->choices; size_t start = (w->worker_num) * c->size / c->worker_count; size_t end = (w->worker_num + 1) * c->size / c->worker_count; @@ -175,6 +175,7 @@ void choices_search(choices_t *c, const char *search) { struct search_job *job = calloc(1, sizeof(struct search_job)); job->search = search; + job->choices = c; /* allocate storage for our results */ c->results = malloc(c->size * sizeof(struct scored_result)); @@ -185,7 +186,6 @@ void choices_search(choices_t *c, const char *search) { struct worker *workers = calloc(c->worker_count, sizeof(struct worker)); for (unsigned int i = 0; i < c->worker_count; i++) { - workers[i].choices = c; workers[i].job = job; workers[i].worker_num = i; workers[i].results = malloc(c->size * sizeof(struct scored_result)); /* FIXME: This is overkill */ |