mirror of
https://github.com/nmap/nmap.git
synced 2026-01-28 17:19:05 +00:00
aaaed61c52959c89109c9d00c5053a7aa2d178ea
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.
Here is some documentation for Nmap, but these files are much less comprehensive than what you'll find at the actual Nmap documentation site ( http://nmap.org ).
Description
Languages
C
37.5%
Lua
28.1%
C++
16.8%
Shell
5.8%
Python
4.2%
Other
7.3%