should probably be type size32_t to match curLen;  unlikely to cause problems in practice.