Question

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.

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top