summaryrefslogtreecommitdiff
path: root/ted.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-08-09 19:14:52 -0300
committerpommicket <pommicket@gmail.com>2023-08-09 19:14:52 -0300
commitcca844b42a6303282e7536c8834b74ff56140cbf (patch)
tree78e58dcbb386c10e0311bfced55f79e251e1a569 /ted.c
parent310faf5d70b8a65c83c013a31ab87d9d3f301767 (diff)
more pointerizing of buffers, fix memory leaks
Diffstat (limited to 'ted.c')
-rw-r--r--ted.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ted.c b/ted.c
index aef59fd..dcc2071 100644
--- a/ted.c
+++ b/ted.c
@@ -491,7 +491,7 @@ void ted_delete_buffer(Ted *ted, TextBuffer *buffer) {
}
Node *ted_new_node(Ted *ted) {
- if (arr_len(ted->nodes) >= 100) { // TODO: constant
+ if (arr_len(ted->nodes) >= TED_NODE_MAX) {
ted_error(ted, "Too many nodes.");
return NULL;
}
@@ -502,13 +502,12 @@ Node *ted_new_node(Ted *ted) {
}
TextBuffer *ted_new_buffer(Ted *ted) {
- if (arr_len(ted->buffers) >= 100) { // TODO: constant
+ if (arr_len(ted->buffers) >= TED_BUFFER_MAX) {
ted_error(ted, "Too many buffers.");
return NULL;
}
- TextBuffer *buffer = ted_calloc(ted, 1, sizeof *buffer);
+ TextBuffer *buffer = buffer_new(ted);
if (!buffer) return NULL;
- buffer_create(buffer, ted);
arr_add(ted->buffers, buffer);
return buffer;
}
@@ -519,7 +518,9 @@ float ted_line_buffer_height(Ted *ted) {
}
void ted_node_switch(Ted *ted, Node *node) {
- assert(node->tabs);
+ while (!node->tabs) {
+ node = node->split_a;
+ }
ted_switch_to_buffer(ted, node->tabs[node->active_tab]);
ted->active_node = node;
}