1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Bug 912, realloc_line: Return the original line->length if successful.

This will let the caller restore the length if it notices it has
allocated too much space.
This commit is contained in:
Kalle Olavi Niemitalo 2006-12-26 14:38:58 +02:00 committed by Kalle Olavi Niemitalo
parent 819653836a
commit 26cce9aab3

View File

@ -154,14 +154,16 @@ realloc_line(struct html_context *html_context, struct document *document,
{ {
struct screen_char *pos, *end; struct screen_char *pos, *end;
struct line *line; struct line *line;
int orig_length;
if (!realloc_lines(document, y)) if (!realloc_lines(document, y))
return -1; return -1;
line = &document->data[y]; line = &document->data[y];
orig_length = line->length;
if (length < line->length) if (length < orig_length)
return 0; return orig_length;
if (!ALIGN_LINE(&line->chars, line->length, length + 1)) if (!ALIGN_LINE(&line->chars, line->length, length + 1))
return -1; return -1;
@ -181,7 +183,7 @@ realloc_line(struct html_context *html_context, struct document *document,
line->length = length + 1; line->length = length + 1;
return 0; return orig_length;
} }
void void