Why does lint not complain in any of the following three lines in the code sample below?
timeout(&a);
timeout(&b);
if (pthread_create(&t1, NULL, timeout, (void*) &a) != 0)
Isn't it in always considered unsafe to pass on a pointer to a local variable? And both variables are local...
#include <stdio.h>
#include <pthread.h>
static void* timeout(void* c)
{
int d = *(*((int**)c));
}
static void sendMessage(int* a)
{
timeout(&a);
int* b = new int(2);
timeout(&b);
pthread_t t1;
if (pthread_create(&t1, NULL, timeout, (void*) &a) != 0)
{
printf("pthread_create() error\n");
}
}
int main()
{
printf("Running..\n");
int* e = new int(1);
sendMessage(e);
delete e;
return 0;
}
Joachim