*/
oldlen = line[0];
lineattrs = line[oldlen + 1];
- line = srealloc(line, TSIZE * (2 + cols));
+ line = sresize(line, 2 + cols, TTYPE);
line[0] = cols;
for (i = oldlen; i < cols; i++)
line[i + 1] = ERASE_CHAR;
* Allocate a new Terminal structure and initialise the fields
* that need it.
*/
- term = smalloc(sizeof(Terminal));
+ term = snew(Terminal);
term->frontend = frontend;
term->ucsdata = ucsdata;
term->cfg = *mycfg; /* STRUCTURE COPY */
term->savecurs.y += 1;
} else {
/* Add a new blank line at the bottom of the screen. */
- line = smalloc(TSIZE * (newcols + 2));
+ line = snewn(newcols + 2, TTYPE);
line[0] = newcols;
for (j = 0; j < newcols; j++)
line[j + 1] = ERASE_CHAR;
term->disptop = 0;
/* Make a new displayed text buffer. */
- newdisp = smalloc(newrows * (newcols + 1) * TSIZE);
+ newdisp = snewn(newrows * (newcols + 1), TTYPE);
for (i = 0; i < newrows * (newcols + 1); i++)
newdisp[i] = ATTR_INVALID;
sfree(term->disptext);
/* Make a new alternate screen. */
newalt = newtree234(NULL);
for (i = 0; i < newrows; i++) {
- line = smalloc(TSIZE * (newcols + 2));
+ line = snewn(newcols + 2, TTYPE);
line[0] = newcols;
for (j = 0; j < newcols; j++)
line[j + 1] = term->erase_char;
term->alt_screen = newalt;
term->alt_sblines = 0;
- term->tabs = srealloc(term->tabs, newcols * sizeof(*term->tabs));
+ term->tabs = sresize(term->tabs, newcols, unsigned char);
{
int i;
for (i = (term->cols > 0 ? term->cols : 0); i < newcols; i++)
if (term->selstart.y >= topline && term->selstart.y <= botline) {
term->selstart.y++;
if (term->selstart.y > botline) {
- term->selstart.y = botline;
+ term->selstart.y = botline + 1;
term->selstart.x = 0;
}
}
if (term->selend.y >= topline && term->selend.y <= botline) {
term->selend.y++;
if (term->selend.y > botline) {
- term->selend.y = botline;
+ term->selend.y = botline + 1;
term->selend.x = 0;
}
}
if (sblen == term->savelines) {
sblen--, line2 = delpos234(term->scrollback, 0);
} else {
- line2 = smalloc(TSIZE * (term->cols + 2));
+ line2 = snewn(term->cols + 2, TTYPE);
line2[0] = term->cols;
term->tempsblines += 1;
}
term->scrolltail->botline == botline) {
term->scrolltail->lines += lines;
} else {
- newscroll = smalloc(sizeof(struct scrollregion));
+ newscroll = snew(struct scrollregion);
newscroll->topline = topline;
newscroll->botline = botline;
newscroll->lines = lines;
ticks = GETTICKCOUNT();
if (!term->beep_overloaded) {
- newbeep = smalloc(sizeof(struct beeptime));
+ newbeep = snew(struct beeptime);
newbeep->ticks = ticks;
newbeep->next = NULL;
if (!term->beephead)
int buflen; /* amount of memory allocated to workbuf */
buflen = 5120; /* Default size */
- workbuf = smalloc(buflen * sizeof(wchar_t));
+ workbuf = snewn(buflen, wchar_t);
wbptr = workbuf; /* start filling here */
old_top_x = top.x; /* needed for rect==1 */
for (p = cbuf; *p; p++) {
/* Enough overhead for trailing NL and nul */
if (wblen >= buflen - 16) {
- workbuf =
- srealloc(workbuf,
- sizeof(wchar_t) * (buflen += 100));
+ buflen += 100;
+ workbuf = sresize(workbuf, buflen, wchar_t);
wbptr = workbuf + wblen;
}
wblen++;
if (term->paste_buffer)
sfree(term->paste_buffer);
term->paste_pos = term->paste_hold = term->paste_len = 0;
- term->paste_buffer = smalloc(len * sizeof(wchar_t));
+ term->paste_buffer = snewn(len, wchar_t);
p = q = data;
while (p < data + len) {