1
0
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:
Alexander Barkov
2018-08-11 19:12:13 +04:00
parent 73a5dd8c54
commit 7a022d7061
3 changed files with 18 additions and 11 deletions

View File

@ -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 */