TODO: check that strdup succeeded or return 1.