* lines. Otherwise, if this function fails in later turns, we will have
* invalid lines in the buffer. */
if (y > con->line_num) {
- tab_ruler = realloc(con->tab_ruler, sizeof(bool) * y);
- if (!tab_ruler)
- return -ENOMEM;
- con->tab_ruler = tab_ruler;
-
cache = realloc(con->lines, sizeof(struct line*) * y);
if (!cache)
return -ENOMEM;
* will guarantee that all lines are big enough so we can resize the
* buffer without reallocating them later. */
if (x > con->size_x) {
+ tab_ruler = realloc(con->tab_ruler, sizeof(bool) * x);
+ if (!tab_ruler)
+ return -ENOMEM;
+ con->tab_ruler = tab_ruler;
+
for (i = 0; i < con->line_num; ++i) {
ret = line_resize(con, con->lines[i], x);
if (ret)
console_scroll_up(con, con->size_y - y);
/* reset tabs */
- for (i = 0; i < y; ++i) {
+ for (i = 0; i < x; ++i) {
if (i % 8 == 0)
con->tab_ruler[i] = true;
else
con->margin_top = 0;
con->margin_bottom = con->size_y - 1;
- for (i = 0; i < con->size_y; ++i) {
+ for (i = 0; i < con->size_x; ++i) {
if (i % 8 == 0)
con->tab_ruler[i] = true;
else