aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/goto.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/goto.c')
-rw-r--r--src/goto.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/goto.c b/src/goto.c
index 42eb964..36002e6 100644
--- a/src/goto.c
+++ b/src/goto.c
@@ -167,12 +167,14 @@ teco_goto_table_find(teco_goto_table_t *ctx, const gchar *name, gsize len)
gssize
teco_goto_table_set(teco_goto_table_t *ctx, const gchar *name, gsize len, gsize pc)
{
- gssize existing_pc = teco_goto_table_find(ctx, name, len);
- if (existing_pc >= 0)
- return existing_pc;
+ teco_goto_label_t *label, *found;
- teco_goto_label_t *label = teco_goto_label_new(name, len, pc);
- teco_rb3str_insert(&ctx->tree, TRUE, &label->head);
+ label = teco_goto_label_new(name, len, pc);
+ found = (teco_goto_label_t *)teco_rb3str_insert(&ctx->tree, TRUE, &label->head);
+ if (found) {
+ teco_goto_label_free(label);
+ return found->pc;
+ }
#ifdef DEBUG
teco_goto_table_dump(ctx);