MCPcopy Index your code
hub / github.com/NetHack/NetHack / cmdbind_add

Function cmdbind_add

src/cmd.c:2125–2155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2123}
2124
2125staticfn void
2126cmdbind_add(uchar key, const struct ext_func_tab *extcmd, boolean user)
2127{
2128 struct Cmd_bind *bind = cmdbind_get(key);
2129
2130 if (!key)
2131 return;
2132 if (!extcmd && bind) {
2133 cmdbind_remove(key);
2134 return;
2135 }
2136
2137 /* binding exists, set it to this command */
2138 if (bind) {
2139 bind->cmd = extcmd;
2140 bind->userbind = user;
2141 if (bind->param) {
2142 free(bind->param);
2143 bind->param = NULL;
2144 }
2145 return;
2146 } else {
2147 bind = (struct Cmd_bind *) alloc(sizeof(struct Cmd_bind));
2148 bind->key = key;
2149 bind->userbind = user;
2150 bind->param = NULL;
2151 bind->cmd = extcmd;
2152 bind->next = gc.Cmd.cmdbinds;
2153 gc.Cmd.cmdbinds = bind;
2154 }
2155}
2156
2157staticfn void
2158cmdbind_remove(uchar key)

Callers 5

bind_keyFunction · 0.85
bind_key_fnFunction · 0.85
commands_initFunction · 0.85
reset_commandsFunction · 0.85
update_rest_on_spaceFunction · 0.85

Calls 3

cmdbind_getFunction · 0.85
cmdbind_removeFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected