Вопрос

I have a function that returns a type of struct that I've defined:

typedef struct irPulseSet
{
    int pulseCount;
    int (*pulses)[2];
} irPulseSet;

irPulseSet irReadPulse()
{
    irPulseSet outputPulseSet;
    //some stuff
    return outputPulseSet;
}

But I'm calling it inside of a loop:

while(1)
{
   irPulseSet currentlPulseSet = irReadPulse();
   //some other stuff here
}

What I want to know is how I would unset currentPulseSet, so it can be set again in the next iteration of the while loop.

Это было полезно?

Решение

The variable currentlPulseSet is living on the stack. When it goes out of scope it will be removed from memory automatically. You don't have to do anything.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top