all marks are now the same size, we just have a pointer for extension.
Signed-off-by: NeilBrown <neil@brown.name>
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;
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);
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;
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) {
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;
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;
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;
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;
}
-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;
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) {
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);