free the memory we allocate to the child name
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 9 Sep 2008 01:07:20 +0000 (11:07 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 9 Sep 2008 01:07:20 +0000 (11:07 +1000)
child.c

diff --git a/child.c b/child.c
index d29c0b640c17128ef112cc4a228d5c86dab3dcec..32f9e42456ecd290acb8e43f97a1760dfc4039bd 100644 (file)
--- a/child.c
+++ b/child.c
@@ -143,6 +143,12 @@ void child_run(struct child_struct *child0, const char *loadfile)
        double targett;
        struct child_struct *child;
 
+       f = fopen(loadfile, "r");
+       if (f == NULL) {
+               perror(loadfile);
+               exit(1);
+       }
+
        for (child=child0;child<child0+options.clients_per_process;child++) {
                child->line = 0;
                asprintf(&child->cname,"client%d", child->id);
@@ -154,12 +160,6 @@ void child_run(struct child_struct *child0, const char *loadfile)
                memset(sparams[i], 0, MAX_PARM_LEN);
        }
 
-       f = fopen(loadfile, "r");
-       if (f == NULL) {
-               perror(loadfile);
-               exit(1);
-       }
-
 again:
        for (child=child0;child<child0+options.clients_per_process;child++) {
                nb_time_reset(child);
@@ -255,5 +255,9 @@ done:
                        nb_ops->cleanup(child);
                }
                child->cleanup_finished = 1;
+               if(child->cname){
+                       free(child->cname);
+                       child->cname = NULL;
+               }
        }
 }