- Introducted Arg2Tcl as a replacement for some calls to Arg2Text
- Fixed a memory leak
This commit is contained in:
13
protocol.c
13
protocol.c
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user