From: NeilBrown Date: Mon, 25 Jan 2016 00:30:49 +0000 (+1100) Subject: Remove 'space' option of mark allocation X-Git-Tag: lca2016~16 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=33a91d55dcf117045cb619ef14887dd0b193925e;p=edlib.git Remove 'space' option of mark allocation all marks are now the same size, we just have a pointer for extension. Signed-off-by: NeilBrown --- diff --git a/core-doc.c b/core-doc.c index 012bb09f..df735862 100644 --- a/core-doc.c +++ b/core-doc.c @@ -34,7 +34,7 @@ struct doc_ref { static int do_doc_destroy(struct doc *d); -static int do_doc_add_view(struct doc *d, struct command *c, int size) +static int do_doc_add_view(struct doc *d, struct command *c) { struct docview *g; int ret; @@ -51,13 +51,11 @@ static int do_doc_add_view(struct doc *d, struct command *c, int size) tlist_add(&g[i].head, GRP_HEAD, &d->views[i].head); tlist_del(&d->views[i].head); g[i].notify = d->views[i].notify; - g[i].space = d->views[i].space; g[i].marked = d->views[i].marked; } for (; i < d->nviews; i++) { INIT_TLIST_HEAD(&g[i].head, GRP_HEAD); g[i].notify = NULL; - g[i].space = 0; g[i].marked = 0; } free(d->views); @@ -66,9 +64,6 @@ static int do_doc_add_view(struct doc *d, struct command *c, int size) points_resize(d); } points_attach(d, ret); - d->views[ret].space = 0; - if (size > 0 && (unsigned)size > sizeof(struct mark)) - d->views[ret].space = size - sizeof(struct mark); d->views[ret].notify = c; d->views[ret].marked = 0; return ret; @@ -459,7 +454,7 @@ DEF_CMD(doc_handle) if (strcmp(ci->key, "doc:add-view") == 0) { if (!ci->comm2) return -1; - return 1 + do_doc_add_view(dd->doc, ci->comm2, ci->extra); + return 1 + do_doc_add_view(dd->doc, ci->comm2); } if (strcmp(ci->key, "doc:del-view") == 0) { diff --git a/core-mark.c b/core-mark.c index 208038a4..d78a5fe8 100644 --- a/core-mark.c +++ b/core-mark.c @@ -138,17 +138,13 @@ static void dup_mark(struct mark *orig, struct mark *new) struct mark *do_mark_at_point(struct doc *d, struct mark *pt, int view) { struct mark *ret; - int size = sizeof(*ret); struct point_links *lnk; if (pt->viewnum != MARK_POINT) return NULL; lnk = pt->mdata; - if (view >= 0) - size += d->views[view].space; - - ret = calloc(size, 1); + ret = calloc(sizeof(*ret), 1); dup_mark(pt, ret); ret->viewnum = view; @@ -234,21 +230,11 @@ void points_attach(struct doc *d, int view) struct mark *mark_dup(struct mark *m, int notype) { struct mark *ret; - int size = sizeof(*ret); - if (!notype) { - struct tlist_head *tl; - struct docview *dv; - if (m->viewnum == MARK_POINT) + if (!notype && m->viewnum == MARK_POINT) return NULL; - tl = &m->view; - while (TLIST_TYPE(tl) != GRP_HEAD) - tl = TLIST_PTR(tl->next); - dv = container_of(tl, struct docview, head); - size += dv->space; - } - ret = calloc(size, 1); + ret = calloc(sizeof(*ret), 1); dup_mark(m, ret); if (notype) { ret->viewnum = MARK_UNGROUPED; @@ -387,13 +373,10 @@ struct mark *doc_prev_mark_all(struct mark *m) struct mark *doc_new_mark(struct doc *d, int view) { struct mark *ret; - int size = sizeof(*ret); if (view == MARK_POINT || view >= d->nviews || d->views[view].notify == NULL) return NULL; - if (view > 0) - size += d->views[view].space; - ret = calloc(size, 1); + ret = calloc(sizeof(*ret), 1); ret->viewnum = view; __mark_reset(d, ret, 1, 0); return ret; diff --git a/core.h b/core.h index e0258732..02faa1e6 100644 --- a/core.h +++ b/core.h @@ -96,7 +96,6 @@ struct doc { struct docview { struct tlist_head head; struct command *notify; - short space; /* extra space to allocate after a mark */ short marked; /* being deleted */ } *views; struct attrset *attrs; @@ -448,14 +447,13 @@ static inline int doc_set_attr(struct pane *p, struct mark *pt, } -static inline int doc_add_view(struct pane *p, struct command *c, int size) +static inline int doc_add_view(struct pane *p, struct command *c) { struct cmd_info ci = {0}; int ret; ci.focus = p; ci.key = "doc:add-view"; ci.comm2 = c; - ci.extra = size; ret = key_handle(&ci); if (ret <= 0) return -1; diff --git a/lib-line-count.c b/lib-line-count.c index ec6b9bcc..a2c9654d 100644 --- a/lib-line-count.c +++ b/lib-line-count.c @@ -131,7 +131,7 @@ static void count_calculate(struct pane *p, struct mark *m, *m2; if (type < 0) - type = doc_add_view(p, &count_notify, 0); + type = doc_add_view(p, &count_notify); m = vmark_first(p, type); if (m == NULL) { diff --git a/render-lines.c b/render-lines.c index 1085c5e8..78e2392c 100644 --- a/render-lines.c +++ b/render-lines.c @@ -1153,7 +1153,7 @@ REDEF_CMD(render_lines_attach) rl->shift_left = 0; rl->header_lines = 0; rl->type = render_lines_notify; - rl->typenum = doc_add_view(ci->focus, &rl->type, 0); + rl->typenum = doc_add_view(ci->focus, &rl->type); rl->pane = pane_register(ci->focus, 0, &render_lines_handle.c, rl, NULL); call3("Request:Notify:Replace", rl->pane, 0, NULL);