C implementation of dynamic lists