compute the length of char* str