Hi guys ,
i got segment fault , and when i trace , found it happens since the value of pointer which is returned by Struct S_client (*ptr) is zero
if (ptr !=0)
i know , adding above line of code is not the solution and not correct for the case since above line only check for the pointer to the address of memory which is not expected for me, i would like to check the value of ptr which is returned in struct s_client , not be zero . so anyone know how could i do that , is appreciated?
Here is the c programming code :
int32_t chk_process (int32_t) {
...
struct s_client *ptr = cur_client();
//FIXME
// how could i check in this line , just when the value of
// ptr is not zero , then it goes to it's next line?`
send_data (ptr, index);
...
...
}
struct s_client *cur_client(void){
return (struct s_client *) pthread_getspecific(getclient);
}
Best Regards.
---------- Post updated at 11:08 AM ---------- Previous update was at 10:39 AM ----------
i think , pthread_getspecific is the case ...
also in man page (qoute from here) :
Since ptr previously might be destroyed (so using if (ptr != 0) ) could not fix the problem , Does anyone know any solution for this problem , i don't know how with pthread_setspecific or any other trick could bypass this segmentation fault.
the reason that i said ptr !=0 is not correct , since i tried with above codes , and still with the if statement i get zero vaule for ptr... (probably because pthread_getspecific , destroyed it before..