Move bufSize calculation into the C level.