3 static Yank yank_buffer;
6 static int read_index, write_index, highest;
10 yank_buffer = (Yank) Malloc(defs.max_yanks*sizeof(YankRec),
11 "while allocating yank buffer", NULL);
12 (void) memset((char *) yank_buffer, 0, defs.max_yanks*sizeof(YankRec));
14 read_index = write_index = 0;
23 if (--read_index < 0) read_index = highest;
24 return &yank_buffer[read_index];
32 if (++read_index > highest) read_index = 0;
33 return &yank_buffer[read_index];
36 void yank_store(dest, msg)
40 yank_buffer[write_index].dest = *dest;
41 if (yank_buffer[write_index].msg)
42 free(yank_buffer[write_index].msg);
43 yank_buffer[write_index].msg = (char *) Malloc(strlen(msg) + 1,
44 "while yanking message",
46 strcpy(yank_buffer[write_index].msg, msg);
49 * read_index = write_index + 1 so that if I follow the store by
50 * a yank_prev I will get the message just stored (since
51 * read_index is decremented before being used). If I do a
52 * yank_next, then read_index will be > highest and reset to zero.
54 read_index = write_index + 1;
55 if (write_index > highest)
56 highest = write_index;
57 write_index = (write_index + 1) % defs.max_yanks;