// This sample is from Neovim's source code.

static int buf_free_count = 0;

typedef enum {
  kBffClearWinInfo = 1,
  kBffInitChangedtick = 2,
} BufFreeFlags;

// Read data from buffer for retrying.
static int
read_buffer(
    int     read_stdin,     // read file from stdin, otherwise fifo
    exarg_T *eap,           // for forced 'ff' and 'fenc' or NULL
    int     flags)          // extra flags for readfile()
{
  int       retval = OK;
  linenr_T  line_count;

  //
  // Read from the buffer which the text is already filled in and append at
  // the end.  This makes it possible to retry when 'fileformat' or
  // 'fileencoding' was guessed wrong.
  //
  line_count = curbuf->b_ml.ml_line_count;
  retval = readfile(
      read_stdin ? NULL : curbuf->b_ffname,
      read_stdin ? NULL : curbuf->b_fname,
      (linenr_T)line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap,
      flags | READ_BUFFER);
  if (retval == OK) {
    // Delete the binary lines.
    while (--line_count >= 0) {
      ml
