memory: xmemcnt(data,c,len).
Squash with refactor str_to_reg.

- xrealloc instead of xmalloc/memcpy.
- Use xmemcnt/STRLEN.