On Mon, 2005-08-15 at 11:03 +0200, Yegor Yefremov wrote:
> Snmpv3_local_snmpEngineTime() gives a difference between start time and
> now in seconds. It means when you change the year you have too big
> difference. But actually one wants to know the time difference from
> system start (snmpv3 engine start time).
>
> So I defined following function in system.c (and added a prototype to
> system.h):
>
> long get_uptime_in_sec(void)
> {
> struct sysinfo *info =
> (struct sysinfo*)malloc(sizeof(struct sysinfo));
>
> if(sysinfo(info) < 0)
> {
> perror("Getting uptime");
> return -1;
> }
>
> return info->uptime;
> }
Two comments/questions:
a) Doesn't this introduce a memory leak?
You appear to be allocating new memory every time that
'get_uptime_in_sec' is called, and never releasing it.
b) What architecture(s) have you tried this with?
How portable is the 'sysinfo' call?
Dave
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders