0
I’m starting to understand pointers better and I’m implementing a queue, and it follows the function:
FILA *removeNodeFIFO(FILA **raiz)
{
FILA *aux = *raiz;
if (aux == NULL)
{
return NULL;
}
else
{
if (aux->prox == NULL)
{
*raiz = NULL;
return aux;
}
else
{
*raiz = aux->prox;
return aux;
}
}
}
I’m going through the root by reference, since I have to update the root and return the deleted element, but I don’t know how I would return the deleted element and then move it out of memory, so I would need to use free(aux) right after Return, how can I release after returned?
By doing so, am I releasing her? supposing I’m calling her in another capacity:
FILA *cel = removeNodeFIFO(&raiz);
...Faço o que preciso com o nó retornado...
free(cel);