setitimer() memory leaks

This is a discussion on setitimer() memory leaks within the C Programming forums, part of the General Programming Boards category; Hey I wanted to know since i used this test portion of code to continously have a repetitive timer. Code: ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    192

    setitimer() memory leaks

    Hey I wanted to know since i used this test portion of code to continously have a repetitive timer.
    Code:
    void alarm_wakeup (int i)
    {
       struct itimerval tout_val;
       signal(SIGALRM,alarm_wakeup);
       howmany += INTERVAL;
       printf("\n%d sec up partner, Wakeup!!!\n",howmany);
       tout_val.it_interval.tv_sec = 0;
       tout_val.it_interval.tv_usec = 0;
       tout_val.it_value.tv_sec = INTERVAL; /* 10 seconds timer */
       tout_val.it_value.tv_usec = 0;
       setitimer(ITIMER_REAL, &tout_val,0);
    }
    That will constanly wake up at every interval does settimer() delete the struct tout_val after it goes off or do i need to free the struct somewhere? I know theres no malloc anywhere in the code but since im declaring the struct over and over everytime does that mean I need to free it?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    If you didn't malloc it, you can't free it. The struct is on the stack, and will be removed when the stack goes away (when the function ends).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking for memory leaks
    By Bladactania in forum C Programming
    Replies: 5
    Last Post: 02-10-2009, 11:58 AM
  2. memory leaks
    By TehOne in forum C Programming
    Replies: 4
    Last Post: 10-10-2008, 09:33 PM
  3. Tons of memory leaks
    By VirtualAce in forum C++ Programming
    Replies: 11
    Last Post: 12-05-2005, 09:19 AM
  4. COM Memory Leaks
    By subdene in forum Windows Programming
    Replies: 0
    Last Post: 06-07-2004, 11:57 AM
  5. about memory leaks with this simple program
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 04-07-2002, 07:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21