Skip to content

Commit

Permalink
:squash: trying to make asan test pass
Browse files Browse the repository at this point in the history
  • Loading branch information
altermo committed Apr 22, 2024
1 parent d5aa55c commit 184ee78
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/nvim/autocmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static AutoPatCmd *active_apc_list = NULL; // stack of active autocommands
// Zero until the group is initialized.
static int deleted_augroup_id = 0;
static const char *deleted_augroup_name = "--Deleted--";
static Set(int) deleted_augroup_map = SET_INIT;

// The ID of the current group.
static int current_augroup = AUGROUP_DEFAULT;
Expand All @@ -110,11 +111,9 @@ static bool autocmd_include_groups = false;

static char *old_termresponse = NULL;

static void augroup_map_del(char *name)
static void augroup_map_del(int id)
{
String *ptr = NULL;
map_del(String, int)(&namespace_ids, cstr_as_string(name), ptr);
xfree(ptr);
set_put(int, &deleted_augroup_map, id);
}

static int get_deleted_augroup_id(void)
Expand Down Expand Up @@ -386,6 +385,10 @@ int augroup_add(const char *name)

int id = (int)nvim_create_namespace(cstr_as_string(name));

if (set_has(int, &deleted_augroup_map, id)) {
set_del(int, &deleted_augroup_map, id);
}

return id;
}

Expand Down Expand Up @@ -435,7 +438,7 @@ void augroup_del(char *name, bool stupid_legacy_mode)
}

// Remove the group because it's not currently in use.
augroup_map_del(name);
augroup_map_del(group);
au_cleanup();
}

Expand All @@ -448,6 +451,9 @@ int augroup_find(const char *name)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
int existing_id = map_get(String, int)(&namespace_ids, cstr_as_string(name));
if (set_has(int, &deleted_augroup_map, existing_id)) {
return AUGROUP_ERROR;
}
if (existing_id > 0) {
return existing_id;
}
Expand Down Expand Up @@ -476,6 +482,9 @@ char *augroup_name(int group)
if (group > next_namespace_id) {
return NULL;
}
if (set_has(int, &deleted_augroup_map, group)) {
return "";
}

String name;
int value;
Expand Down Expand Up @@ -515,11 +524,10 @@ void do_augroup(char *arg, bool del_group)
String name;
int value;
map_foreach(&namespace_ids, name, value, {
if (value > 0) {
if (value > 0 && !set_has(int, &deleted_augroup_map, value)) {
msg_puts(name.data);
msg_puts(" ");
}

msg_puts(" ");
});

msg_clr_eos();
Expand Down

0 comments on commit 184ee78

Please sign in to comment.