# include "Ximage.h"

int EraseOverlay (Graphic *graphic, Layout *layout) {

  char buffer[256];
  int i, status, N;

  fcntl (layout[0].Ximage, F_SETFL, !O_NONBLOCK);  
  status = read (layout[0].Ximage, buffer, 16); 
  buffer[16] = 0; 
  sscanf (buffer, "%*s %d", &N); 
  if (N > NOVERLAYS) {
    REALLOCATE (layout[0].tickmarks.objects, Object, 1);
    layout[0].tickmarks.Nobjects = 0;
  } else {
    for (i = 0; i < layout[0].overlay[N].Nobjects; i++) {
      if (!strcmp (layout[0].overlay[N].objects[i].type, "TEXT")) {
	free (layout[0].overlay[N].objects[i].text);
      }
    }
    REALLOCATE (layout[0].overlay[N].objects, Object, 1);
    layout[0].overlay[N].Nobjects = 0;
    OVERLAY[N] = FALSE;
  }

  if (USE_XWINDOW) Refresh (graphic, layout, 0);

  fcntl (layout[0].Ximage, F_SETFL, O_NONBLOCK);  
  return (TRUE);
}
