]> git.neil.brown.name Git - edlib.git/commitdiff
Discard edlib_do_free()
authorNeilBrown <neil@brown.name>
Fri, 8 Sep 2023 09:41:59 +0000 (19:41 +1000)
committerNeilBrown <neil@brown.name>
Fri, 8 Sep 2023 09:50:23 +0000 (19:50 +1000)
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 <neil@brown.name>
core-editor.c
core-pane.c
core-pane.h
core.h

index 02005cafb7158257ab256253efb5c5525ceaa71b..89e8f1a3cf913da0f362225abbdd9c0b8b674289 100644 (file)
@@ -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.
  */
index 15cb21104e85069d3cd78e09e9a214230c625d30..6d05ac3f9fd302e390da3097c7e2eb56163b2615 100644 (file)
@@ -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)
index 44fb1929758141ca147ded34ffec7c5431d0960e..e1d1b99db9ee1f016c9564700f8b9613cbe004e3 100644 (file)
@@ -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 0c8598738069b54b07c93477e05a4a16d9cf10c6..12a19116285348e971a97b3cd5504833c1b54a23 100644 (file)
--- 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);