struct sigevent timerEvent;
memset(&timerEvent, 0, sizeof(timerEvent));
timerEvent.sigev_value.sival_int = 0;
timerEvent.sigev_value.sival_ptr = diaBase;
timerEvent.sigev_notify = SIGEV_THREAD;
timerEvent._sigev_un._sigev_thread._function = function;
timerEvent._sigev_un._sigev_thread._attribute = NULL;
timer_t timer_ID;
int retVal;
if((retVal = timer_create (CLOCK_REALTIME, &timerEvent, &timer_ID )) != -1)
{
printf("Timer Created Successfully: %ld\n", timer_ID );
}
else
{
printf("Error Creating Timer\n");
}
Memory Leak, the following denotes
Syscall param timer_create(evp) points to uninitialised byte(s)
==27384== at 0x530595: timer_create (in /lib/librt-2.5.so)
This seems to be a known valgrind issue:
http://bugs.kde.org/show_bug.cgi?id=124478
...and...
http://www.google.co.uk/search?source=ig&hl=en&rlz=&q=Syscall+param+timer_create%28evp%29+points+to+uninitialised+byte%28s%29&btnG=Google+Search
Had the same problem and made valgrind happy with this:
timer_t timerId;
struct sigevent* sigev = static_cast<struct sigevent*>(calloc(1, sizeof(struct sigevent)));
sigev->sigev_notify = SIGEV_SIGNAL;
sigev->sigev_signo = SIGALRM;
sigev->sigev_value.sival_ptr = &timerId;
timer_create(CLOCK_REALTIME, sigev, &timerId);
// Use the timer
...
// After totally done with the timer
free(sigev);
I used this as a reference: http://pubs.opengroup.org/onlinepubs/7908799/xsh/timer_create.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With