Re: gettimeofday segfaults with malloc but not calloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2009-01-13 at 10:51 +0100, Henrik Austad wrote:
> I'm using gettimeofday to get the most accurate time from the kernel
> 
> When I use calloc to create and initalize memory for the struct timeval *tv, 
> everything works fine: 
> 
> struct timeval *tv;
> tv = (struct timeval *)calloc(1, sizeof(struct timeval));
> if (!tv) {
>   /* handle error... */
>   exit
> }
> gettimeofday(tv);

Did you read the man page?
You are missing a #include below. If you add that you would see that you
gettimeofday() has two parameters.

[...]
	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services



--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux