context_t context = xbt_new0(s_context_t,1);\r
\r
context->line = NULL;\r
+ context->pos = NULL;\r
context->command_line = NULL;\r
context->exit_code = 0;\r
context->timeout = INDEFINITE;\r
int\r
context_free(context_t* ptr)\r
{\r
- /* TODO : check the parameter */\r
if(((*ptr)->input))\r
xbt_strbuff_free(((*ptr)->input));\r
\r
if(((*ptr)->output))\r
xbt_strbuff_free(((*ptr)->output));\r
\r
+ if((*ptr)->command_line)\r
+ free((*ptr)->command_line);\r
+\r
+ if((*ptr)->pos)\r
+ free((*ptr)->pos);\r
+\r
if((*ptr)->signal)\r
free((*ptr)->signal);\r
\r
int\r
context_reset(context_t context)\r
{\r
- \r
- /* TODO : check the parameter */\r
- \r
context->line = NULL;\r
- context->command_line = NULL;\r
+ context->pos = NULL;\r
+\r
+ if(context->command_line)\r
+ {\r
+ free(context->command_line);\r
+ context->command_line = NULL;\r
+ }\r
+\r
+ if(context->pos)\r
+ {\r
+ free(context->pos);\r
+ context->pos = NULL;\r
+ }\r
\r
if(context->input)\r
xbt_strbuff_empty(context->input);\r
context_t\r
context_dup(context_t context)\r
{\r
- \r
context_t dup;\r
\r
- /* TODO : check the parameter */\r
- \r
dup = xbt_new0(s_context_t, 1);\r
\r
dup->line = context->line;\r
- dup->command_line = context->command_line;\r
+ dup->pos = strdup(context->pos);\r
+ dup->command_line = strdup(context->command_line);\r
dup->exit_code = context->exit_code;\r
dup->timeout = context->timeout;\r
dup->output = NULL;\r
dup->input = xbt_strbuff_new();\r
xbt_strbuff_append(dup->input,context->input->data);\r
}\r
+ \r
+ dup->output = xbt_strbuff_new();\r
\r
if(context->output->used)\r
{\r
- dup->output = xbt_strbuff_new();\r
xbt_strbuff_append(dup->output,context->output->data);\r
}\r
\r
context_clear(context_t context)\r
{\r
context->line = NULL;\r
- context->command_line = NULL;\r
+ context->pos = NULL;\r
+ \r
+ if(context->command_line)\r
+ {\r
+ free(context->command_line);\r
+ context->command_line = NULL;\r
+ }\r
+\r
+ if(context->pos)\r
+ {\r
+ free(context->pos);\r
+ context->pos = NULL;\r
+ }\r
+\r
context->exit_code = 0;\r
context->timeout = INDEFINITE;\r
\r