我想在C線程工作,我有一些問題,釋放的指針 如果這是線程函數線程空閒指針
void *executor_func(void *param) {
char *lineEx = (char *) malloc (1024);
size_t lenEx = 1024;
ssize_t readEx;
FILE * fpEx;
char* pchEx;
fpEx = fopen(file, "r");
if (fpEx == NULL) {
printf("ERROR: couldnt open file\n");
exit(0);
}
while ((readEx = getline(&lineEx, &lenEx, fpEx)) != -1) {
pchEx = strtok(lineEx, " ");
//DO MY STUFF WITH THE LINE I RECEIVE FROM FILE
}
free(lineEx);
fclose(fpEx);
return NULL;
}
想象一下,我執行executor_func的多線程( )... 免費(lineEX)在Valgrind給我提問...爲什麼是這樣?
什麼是你得到具體的錯誤? – 2013-04-11 20:28:19