version 1.14 | | version 1.15 |
---|
| | |
/* | | /* |
* static char *rcsid_plugins_c = | | * static char *rcsid_plugins_c = |
* "$Id: plugins.c,v 1.14 2002/02/06 05:54:47 mwedel Exp $"; | | * "$Id: plugins.c,v 1.15 2002/02/22 09:47:39 gros Exp $"; |
*/ | | */ |
| | |
/*****************************************************************************/ | | /*****************************************************************************/ |
| | |
/*****************************************************************************/ | | /*****************************************************************************/ |
CommArray_s *find_plugin_command(char *cmd, object *op) | | CommArray_s *find_plugin_command(char *cmd, object *op) |
{ | | { |
CFParm* CmdParm; | | CFParm CmdParm; |
CFParm* RTNValue; | | CFParm* RTNValue; |
int i; | | int i; |
char cmdchar[10]; | | char cmdchar[10]; |
CommArray_s *RTNCmd; | | static CommArray_s RTNCmd; |
| | |
strcpy(cmdchar,"command?"); | | strcpy(cmdchar,"command?"); |
/* Why do a malloc/free? Would be a lot faster to just declare | | CmdParm.Value[0] = cmdchar; |
* it as a non pointer. | | CmdParm.Value[1] = cmd; |
*/ | | CmdParm.Value[2] = op; |
CmdParm = (CFParm *)(malloc(sizeof(CFParm))); | | |
CmdParm->Value[0] = cmdchar; | | |
CmdParm->Value[1] = cmd; | | |
CmdParm->Value[2] = op; | | |
| | |
for(i=0;i<PlugNR;i++) | | for(i=0;i<PlugNR;i++) |
{ | | { |
RTNValue = PlugList[i].propfunc(CmdParm); | | RTNValue = (PlugList[i].propfunc(&CmdParm)); |
if (RTNValue!=NULL) | | if (RTNValue!=NULL) |
{ | | { |
RTNCmd = (CommArray_s *)(malloc(sizeof(CommArray_s))); | | RTNCmd.name = (char *)(RTNValue->Value[0]); |
RTNCmd->name = (char *)(RTNValue->Value[0]); | | RTNCmd.func = (CommFunc)(RTNValue->Value[1]); |
RTNCmd->func = (CommFunc)(RTNValue->Value[1]); | | RTNCmd.time = *(float *)(RTNValue->Value[2]); |
RTNCmd->time = *(float *)(RTNValue->Value[2]); | | printf("RTNCMD: name %s, time %d\n", RTNCmd.name, RTNCmd.time); |
/* Note that this is a memory leak here also, because the | | return &RTNCmd; |
* caller doesn't free this data. Probably better to | | |
* make RTNCmd a static - that will work unless this function | | |
* needs to be recursive or crossfire becomes threaded | | |
*/ | | |
free(CmdParm); | | |
return RTNCmd; | | |
}; | | }; |
}; | | }; |
free(CmdParm); | | |
return NULL; | | return NULL; |
}; | | }; |
| | |