take into account offset when computing buffer size