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.

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top