D'oh! I don't see why that should be avoiding normal string routines, so I instead just snarfed the loop from the vanilla unsetenv, which does the same but using strncmp.