I've a little confusion with structs and free operation in C. I have to use this struct ( I know is no best idea define *tList instead of tList but it must be that way)
typedef struct cel{
int elto;
struct cel *bif;
struct cel *next;
} *tList;
bif point to previus element, so y don't free() because i think its no necesary
Malloc tList list=(tList)malloc(sizeof(struct cel));
And later I need to free memory. I don't know what way is correct
call limpiar with list
void limpiar (tList borrar)
{
tList aux;
tList aBorrar;
for(aBorrar = borrar; aBorrar != NULL; aBorrar = aux)
{
aux=aBorrar->next;
free(aBorrar);
}
return;
}
or
call limpiar with &list
void limpiar (tList * borrar)
{
tList aux;
tList aBorrar;
for(aBorrar = *borrar; aBorrar != NULL; aBorrar = aux)
{
aux=aBorrar->next;
free(aBorrar);
}
return;
}