MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Cmd_AddCommand

Function Cmd_AddCommand

code/qcommon/cmd.cpp:609–629  ·  view source on GitHub ↗

============ Cmd_AddCommand ============ */

Source from the content-addressed store, hash-verified

607============
608*/
609void Cmd_AddCommand( const char *cmd_name, xcommand_t function ) {
610 cmd_function_t *cmd;
611
612 // fail if the command already exists
613 if( Cmd_FindCommand( cmd_name ) )
614 {
615 // allow completion-only commands to be silently doubled
616 if ( function != NULL ) {
617 Com_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name);
618 }
619 return;
620 }
621
622 // use a small malloc to avoid zone fragmentation
623 cmd = (struct cmd_function_s *)S_Malloc (sizeof(cmd_function_t));
624 cmd->name = CopyString( cmd_name );
625 cmd->function = function;
626 cmd->complete = NULL;
627 cmd->next = cmd_functions;
628 cmd_functions = cmd;
629}
630
631/*
632============

Callers 14

Com_InitFunction · 0.70
FS_StartupFunction · 0.70
Cmd_InitFunction · 0.70
Cvar_InitFunction · 0.70
Com_InitZoneMemoryVarsFunction · 0.70
Sys_InitFunction · 0.50
WIN_InitFunction · 0.50
Con_InitFunction · 0.50
CL_InitInputFunction · 0.50
snd_dma.cppFile · 0.50
CL_InitKeyCommandsFunction · 0.50
CL_InitFunction · 0.50

Calls 4

Cmd_FindCommandFunction · 0.70
Com_PrintfFunction · 0.70
S_MallocFunction · 0.70
CopyStringFunction · 0.70

Tested by

no test coverage detected