sled

Једноставни уређивач текста
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување d2fd74cb080f794c4f64dac569198ef7c285b233
родитељ 3bc96ad4e58536669049e5932212ce42100546c7
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sat, 19 Feb 2022 00:22:27 +0100

sled.c: Add variable to represent an expression; remove extra comments

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
Msled.c | 14+++++---------
измењених датотека: 1, додавања: 5(+), брисања: 9(-)

diff --git a/sled.c b/sled.c @@ -857,6 +857,7 @@ int insert_line(struct DrawState* state) { struct BufferLine* newchunk = NULL; + struct BufferLine* line = NULL; uint32_t* newtext = NULL; state->rows_count++; @@ -872,8 +873,9 @@ insert_line(struct DrawState* state) } state->buffer = newchunk; } - init_bufferline(&state->buffer[state->rows_count - 1]); - if (!state->buffer[state->rows_count - 1].text) + line = state->buffer + state->rows_count - 1; + init_bufferline(line); + if (!line->text) { newtext = calloc(MAXBUFLINE, sizeof(uint32_t)); if (!newtext) @@ -881,7 +883,7 @@ insert_line(struct DrawState* state) strcpy(state->error, errors[ERR_CANT_ALLOC]); return 0; } - state->buffer[state->rows_count - 1].text = newtext; + line->text = newtext; } for (size_t i = state->rows_count - 1; i > state->row + 1; i--) { @@ -968,15 +970,9 @@ join_lines(struct DrawState* state, size_t first_line, int forward) MAXBUFLINE); state->buffer[i].length = state->buffer[i + 1].length; } - /*free_bufferline(state->buffer + state->rows_count - 1);*/ *state->buffer[state->rows_count - 1].text = 0; state->buffer[state->rows_count - 1].length = 0; state->rows_count--; - /*struct BufferLine* newbuf = realloc(state->buffer, - state->buffer_size * sizeof(struct BufferLine)); - if (!newbuf) - return NULL; - state->buffer = newbuf;*/ state->dirty = 1; return state; }