worker_id may not be initialised if we start from C-level.

This commit is contained in:
Vitor Santos Costa 2012-12-10 12:13:31 +00:00
parent 62aa6df644
commit 9e63e83f1f

View File

@ -4786,6 +4786,7 @@ struct PL_local_data *Yap_InitThreadIO(int wid)
{
CACHE_REGS
struct PL_local_data *p;
fprintf(stderr,"wid=%d\n", wid);
if (wid)
p = (struct PL_local_data *)malloc(sizeof(struct PL_local_data));
else
@ -4796,10 +4797,10 @@ struct PL_local_data *Yap_InitThreadIO(int wid)
}
#if THREADS
if (wid) {
/* copy from other worker */
memcpy(p, Yap_local[worker_id]->PL_local_data_p_, sizeof(struct PL_local_data));
memcpy(p, Yap_local[0]->PL_local_data_p_, sizeof(struct PL_local_data));
}
#endif
fprintf(stderr,"wid=%d done\n", wid);
return p;
}