]> git.neil.brown.name Git - edlib.git/commitdiff
Remove 'space' option of mark allocation
authorNeilBrown <neil@brown.name>
Mon, 25 Jan 2016 00:30:49 +0000 (11:30 +1100)
committerNeilBrown <neil@brown.name>
Mon, 25 Jan 2016 00:30:49 +0000 (11:30 +1100)
all marks are now the same size,  we just have a pointer for extension.

Signed-off-by: NeilBrown <neil@brown.name>
core-doc.c
core-mark.c
core.h
lib-line-count.c
render-lines.c

index 012bb09f3a8da549975338d4bd173e7af06c3383..df7358627a5d3eaeb080280608d62c9adc24ffbd 100644 (file)
@@ -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) {
index 208038a48e1abe5c018a3eadf1ecb78fe5eb716c..d78a5fe8d28c107dadea857c08c371740869f7dd 100644 (file)
@@ -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 e025873275430120ff0535e998c43951d8886ea3..02faa1e662edd043db1271ffcd034309eddd5493 100644 (file)
--- 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;
index ec6b9bcc587d8ef22fbfa8373df71e63f422ad65..a2c9654d5b5ea12c9b66b5e0d8e8d53aa825db78 100644 (file)
@@ -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) {
index 1085c5e8520347f822b9c3ddd6c4e3b3d756a952..78e2392c2c24ba341cf62ae43ba42d0adc3e633a 100644 (file)
@@ -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);