The second parameter passed into getline(3) is the size of the allocated buffer, *NOT* the length of the returned line. This can be confusing, so rename this parameter as 'allocsize' consistently throughout the code. This is just code motion.