Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is the third parameter to CNET_start_timer ever used for?

parameter Used
0
Posted

What is the third parameter to CNET_start_timer ever used for?

0

Any value passed as the third parameter to CNET_start_timer is remembered, internally, along with the timer. When the timer expires, this saved value is passed as the third parameter to the handler for the timer’s event. This parameter is of type CnetData (a long integer in C) which allows it to store integral values or a pointer to a variable or dynamically allocated data structure. Typical uses for this parameter are to pass a sequence number used in a protocol, or perhaps a pointer to a list or tree structure, to the timer event’s handler. If the parameter is used to store a pointer, care must be taken to ensure that the pointer is still valid at the time the timer’s event handler is called. In particular, the parameter should never be used to store the address of any variable or structure on C’s runtime stack. It is reasonable to pass a pointer to dynamically allocated storage to CNET_start_timer (i.e. allocated with malloc), and then have the timer’s event handler deallocate this

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123