mirror of
https://github.com/nmap/nmap.git
synced 2026-01-31 02:29:02 +00:00
it started by allocating six times the size of the input string because in the worst case each byte can take up to six bytes when escaped (&#xXX;). It was wasteful of time because it built the string up with strncat, which pads the entire destination buffer with null bytes every time it was called. This led to quadratic time complexity, not linear as expected. The new version uses the usual strategy of doubling the size of the buffer whenever it runs out of space. It builds up the string using memcpy, checking each time that there is space for the new copy.
75 KiB
75 KiB