this doesn't compile for me. Seems len is set to ptr.