mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 19:55:10 +00:00
[FIX] Make Parsee build on GCC without warns
This commit is contained in:
parent
1d188069db
commit
907ac13da9
20 changed files with 72 additions and 20 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue