This whole dance with current and next would make more sense if you were to actually free(current); at some point; as it is, you're leaking it ...