From: NeilBrown Date: Fri, 8 Sep 2023 09:41:59 +0000 (+1000) Subject: Discard edlib_do_free() X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=f00c9e6126a221bafba0ac404bdb2126a7a4102d;p=edlib.git Discard edlib_do_free() No code uses this any more, so discard it. Also change pane->data_size to pane->alloc_size and use it for accounting when freeing the pane. Signed-off-by: NeilBrown --- diff --git a/core-editor.c b/core-editor.c index 02005caf..89e8f1a3 100644 --- a/core-editor.c +++ b/core-editor.c @@ -342,13 +342,6 @@ DEF_CMD(editor_free_store) return 1; } -DEF_EXTERN_CMD(edlib_do_free) -{ - if (ci->home->data_size) - unalloc_buf_safe(ci->home->_data, ci->home->data_size, pane); - return 1; -} - /* FIXME I should be able to remove things from a keymap, not * replace with this. */ diff --git a/core-pane.c b/core-pane.c index 15cb2110..6d05ac3f 100644 --- a/core-pane.c +++ b/core-pane.c @@ -156,17 +156,18 @@ static struct pane *_do_pane_register(struct pane *parent, short z, if (data) alloc_size = sizeof(data); + alloc_size += offsetof(struct pane, data); - p = alloc_zbuf(offsetof(struct pane, data) + alloc_size, pane); + p = alloc_zbuf(alloc_size, pane); pane_init(p, parent); + p->alloc_size = alloc_size; p->z = z; if (parent) p->abs_z = parent->abs_z + 1; p->handle = command_get(handle); - if (data) { + if (data) p->data = data; - p->data_size = data_size; - } + p->name = handle->name; if (z >= 0) { if (parent && parent->focus == NULL) @@ -639,7 +640,7 @@ void pane_close(struct pane *p safe) void pane_free(struct pane *p safe) { if (p->refs == 0) - unalloc_safe(p, pane); + unalloc_buf_safe(p, p->alloc_size, pane); } bool pane_resize(struct pane *p safe, int x, int y, int w, int h) diff --git a/core-pane.h b/core-pane.h index 44fb1929..e1d1b99d 100644 --- a/core-pane.h +++ b/core-pane.h @@ -10,7 +10,7 @@ struct pane { short abs_z; short damaged; - short data_size; /* only needed by edlib_do_free */ + short alloc_size; int marks; int refs; diff --git a/core.h b/core.h index 0c859873..12a19116 100644 --- a/core.h +++ b/core.h @@ -339,7 +339,6 @@ struct lookup_cmd { .m = &_map, \ } -DECL_EXTERN_CMD(edlib_do_free); DECL_EXTERN_CMD(edlib_noop); int key_lookup_cmd_func(const struct cmd_info *ci safe);