diff options
Diffstat (limited to 'src/goto.c')
| -rw-r--r-- | src/goto.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -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); |
