MCPcopy Create free account
hub / github.com/NetHack/NetHack / remember_topl

Function remember_topl

win/tty/topl.c:169–191  ·  view source on GitHub ↗

used by update_topl(); also by tty_putstr() */

Source from the content-addressed store, hash-verified

167
168/* used by update_topl(); also by tty_putstr() */
169void
170remember_topl(void)
171{
172 struct WinDesc *cw = wins[WIN_MESSAGE];
173 int idx = cw->maxrow;
174 unsigned len = strlen(gt.toplines) + 1;
175
176 if ((cw->flags & WIN_LOCKHISTORY) || !*gt.toplines)
177 return;
178
179 if (len > (unsigned) cw->datlen[idx]) {
180 if (cw->data[idx])
181 free(cw->data[idx]);
182 len += (8 - (len & 7)); /* pad up to next multiple of 8 */
183 cw->data[idx] = (char *) alloc(len);
184 cw->datlen[idx] = (short) len;
185 }
186 Strcpy(cw->data[idx], gt.toplines);
187 if (!program_state.in_checkpoint) {
188 *gt.toplines = '\0';
189 cw->maxcol = cw->maxrow = (idx + 1) % cw->rows;
190 }
191}
192
193void
194addtopl(const char *s)

Callers 4

update_toplFunction · 0.85
msghistory_snapshotFunction · 0.85
tty_putmsghistoryFunction · 0.85
tty_putstrFunction · 0.85

Calls 1

allocFunction · 0.50

Tested by

no test coverage detected