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