[FIX] Make Parsee build on GCC without warns

This commit is contained in:
LDA 2024-09-10 22:20:13 +02:00
commit 907ac13da9
20 changed files with 72 additions and 20 deletions

View file

@ -15,35 +15,47 @@ CommandCreateRouter(void)
void
CommandAddCommand(CommandRouter *rter, char *c, CommandRoute rte)
{
CommandRoute *indirect;
if (!rter || !c || !rte)
{
return;
}
HashMapSet(rter->routes, c, rte);
/* Little dirty trick to force C99 into submission, and since
* some architectures may separate data/code. Still don't like it... */
indirect = Malloc(sizeof(rte));
*indirect = rte;
HashMapSet(rter->routes, c, (void *) indirect);
}
void
RouteCommand(CommandRouter *rter, Command *cmd, void *d)
{
CommandRoute route;
CommandRoute *route;
if (!rter || !cmd)
{
return;
}
route = HashMapGet(rter->routes, cmd->command);
if (route)
if (route && *route)
{
route(cmd, d);
(*route)(cmd, d);
}
}
void
CommandFreeRouter(CommandRouter *rter)
{
char *key;
CommandRoute *val;
if (!rter)
{
return;
}
while (HashMapIterate(rter->routes, &key, (void **) &val))
{
Free(val);
}
HashMapFree(rter->routes);
Free(rter);
}