mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
A cleanup for MDEV-16939: avoid timeval initialization related problems in the future (compilation failures on Windows)
Adding a helper class Timeval, to initialize "struct timeval" in a safe way. As a bonus, adding a method Timeval::trunc(), so the caller now can have one line instead of five lines (declaration, initializations of sec and usec, truncation, passing to store_TIMEVAL()).
This commit is contained in:
@ -831,4 +831,20 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class Timeval: public timeval
|
||||
{
|
||||
public:
|
||||
Timeval(my_time_t sec, ulong usec)
|
||||
{
|
||||
tv_sec= sec;
|
||||
tv_usec= usec;
|
||||
}
|
||||
Timeval &trunc(uint dec)
|
||||
{
|
||||
my_timeval_trunc(this, dec);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* STRUCTS_INCLUDED */
|
||||
|
Reference in New Issue
Block a user