- Introducted Arg2Tcl as a replacement for some calls to Arg2Text

- Fixed a memory leak
This commit is contained in:
zolliker
2006-04-11 07:26:55 +00:00
parent e25fb68080
commit da3dfd9d76
11 changed files with 184 additions and 92 deletions

View File

@ -171,7 +171,8 @@ void DeleteProtocol(void *self)
static int ContextDo(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]){
commandContext comCon;
char command[1024];
char buffer[1024];
char *command;
int status;
if(argc < 3){
@ -186,11 +187,15 @@ static int ContextDo(SConnection *pCon, SicsInterp *pSics, void *pData,
return 0;
}
strncpy(comCon.deviceID,argv[2],SCDEVIDLEN);
memset(command,0,1024*sizeof(char));
Arg2Text(argc-2,&argv[2],command,1023);
memset(buffer,0,sizeof(buffer));
command = Arg2Tcl(argc-2,&argv[2],buffer,sizeof buffer);
if (!command) {
SCWrite(pCon,"ERROR: no more memory",eError);
return 0;
}
SCPushContext2(pCon,comCon);
status = InterpExecute(pSics,pCon,command);
if (command != buffer) free(command);
SCPopContext(pCon);
return status;
}