Skip to content

Commit 039b9ef

Browse files
Russell StewartRussell Stewart
authored andcommitted
Fixed pointer dereference to long long warning.
1 parent 8d0f870 commit 039b9ef

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/glove.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void initialize_parameters() {
8282
/* Train the GloVe model */
8383
void *glove_thread(void *vid) {
8484
long long a, b ,l1, l2;
85-
long long id = (long long) vid;
85+
long long id = *(long long*)vid;
8686
CREC cr;
8787
real diff, fdiff, temp1, temp2;
8888
FILE *fin;
@@ -253,7 +253,9 @@ int train_glove() {
253253
total_cost = 0;
254254
for (a = 0; a < num_threads - 1; a++) lines_per_thread[a] = num_lines / num_threads;
255255
lines_per_thread[a] = num_lines / num_threads + num_lines % num_threads;
256-
for (a = 0; a < num_threads; a++) pthread_create(&pt[a], NULL, glove_thread, (void *)a);
256+
long long *thread_ids = (long long*)malloc(sizeof(long long) * num_threads);
257+
for (a = 0; a < num_threads; a++) thread_ids[a] = a;
258+
for (a = 0; a < num_threads; a++) pthread_create(&pt[a], NULL, glove_thread, (void *)&thread_ids[a]);
257259
for (a = 0; a < num_threads; a++) pthread_join(pt[a], NULL);
258260
for (a = 0; a < num_threads; a++) total_cost += cost[a];
259261
fprintf(stderr,"iter: %03d, cost: %lf\n", b+1, total_cost/num_lines);

0 commit comments

Comments
 (0)