summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3275e10)
raw | patch | inline | side by side (parent: 3275e10)
author | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 14 Jan 2009 12:31:19 +0000 (13:31 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Thu, 15 Jan 2009 14:57:05 +0000 (15:57 +0100) |
tig.c | patch | blob | history |
index b553b4d71f3336fc8926423ddc472b4bb24695ed..4eafe767a7d894084e4d302e7a471dc801aa0545 100644 (file)
--- a/tig.c
+++ b/tig.c
size_t lines; /* Total number of lines */
struct line *line; /* Line index */
size_t line_alloc; /* Total number of allocated lines */
- size_t line_size; /* Total number of used lines */
unsigned int digits; /* Number of digits in the lines member. */
/* Drawing */
view->offset = 0;
view->lines = 0;
view->lineno = 0;
- view->line_size = 0;
view->line_alloc = 0;
view->vid[0] = 0;
view->update_secs = 0;
view->line = tmp;
view->line_alloc = alloc;
- view->line_size = line_size;
return view->line;
}
}
}
- if (!realloc_lines(view, view->lines + 1) ||
- !view->ops->read(view, line))
+ if (!view->ops->read(view, line))
goto alloc_error;
}
static struct line *
add_line_data(struct view *view, void *data, enum line_type type)
{
- struct line *line = &view->line[view->lines++];
+ struct line *line;
+
+ if (!realloc_lines(view, view->lines + 1))
+ return NULL;
+ line = &view->line[view->lines++];
memset(line, 0, sizeof(*line));
line->type = type;
line->data = data;
+ line->dirty = 1;
return line;
}
if (bufpos == 0)
return;
- if (!realloc_lines(view, view->line_size + 1))
- return;
-
add_line_text(view, buf, LINE_PP_REFS);
}
if (first_read) {
/* Add path info line */
if (!string_format(buf, "Directory path /%s", opt_path) ||
- !realloc_lines(view, view->line_size + 1) ||
!add_line_text(view, buf, LINE_DEFAULT))
return FALSE;
/* Insert "link" to parent directory. */
if (*opt_path) {
if (!string_format(buf, TREE_UP_FORMAT, view->ref) ||
- !realloc_lines(view, view->line_size + 1) ||
!add_line_text(view, buf, LINE_TREE_DIR))
return FALSE;
}
@@ -4260,14 +4256,9 @@ status_run(struct view *view, const char *argv[], char status, enum line_type ty
while ((buf = io_get(&io, 0, TRUE))) {
if (!file) {
- if (!realloc_lines(view, view->line_size + 1))
- goto error_out;
-
file = calloc(1, sizeof(*file));
- if (!file)
+ if (!file || !add_line_data(view, file, type))
goto error_out;
-
- add_line_data(view, file, type);
}
/* Parse diff info part. */
reset_view(view);
- if (!realloc_lines(view, view->line_size + 7))
- return FALSE;
-
add_line_data(view, NULL, LINE_STAT_HEAD);
if (is_initial_commit())
string_copy(status_onbranch, "Initial commit");