summaryrefslogtreecommitdiffstats
path: root/src/dfxml.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2011-11-05 11:41:14 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2011-11-05 11:41:14 +0100
commitd86b025fb2dbda42975ac14d5d37908297332004 (patch)
tree9022f033c8518eed9cc4a1df9efe2e235b31ac75 /src/dfxml.c
parentc4ab5f6a0b8e2536a45129a6bde54df878a2900d (diff)
Modify xml_set_command_line to avoid using realloc
Diffstat (limited to 'src/dfxml.c')
-rw-r--r--src/dfxml.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/dfxml.c b/src/dfxml.c
index b35908f..b621748 100644
--- a/src/dfxml.c
+++ b/src/dfxml.c
@@ -80,11 +80,18 @@ FILE *xml_open(const char *recup_dir, const unsigned int dir_num)
void xml_set_command_line(const int argc, char **argv)
{
int i;
- command_line = (char *)calloc(1, 1);
+ int len=argc;
+ if(command_line!=NULL)
+ return ;
/* Capture the command line */
for(i=0; i<argc; i++)
{
- command_line = (char *)realloc(command_line, strlen(command_line) + 2 + strlen(argv[i]));
+ len+=strlen(argv[i]);
+ }
+ command_line = (char *)MALLOC(len);
+ command_line[0]='\0';
+ for(i=0; i<argc; i++)
+ {
if(i>0)
strcat(command_line," ");
strcat(command_line, argv[i]);