Why ptr->length - 1? Doesn't that leave out the trailing zero byte?