populating char**
<p>I'm trying to read in a list of files from another file.  The file reading works but populating the array of char* isn't.  It works for the first iteration but then gets a bad pointer on the next line.  I tried with a vector of strings but was having problems, I think due to its destructor trying to free an argv.</p>

<pre><code>char **datafiles = (char**)malloc(0);
int filecount = 0;

master.AddDataFiles(argv[1],datafiles,filecount);

int Manager::AddDataFiles(char *filename, char **filelist, int &amp;filecount)
{
    const int LINEMAX = 64;
    struct stat info;
    std::ifstream is(filename);
    if (is.fail()) return 1;

    char buffer[LINEMAX];

    while(!is.eof())
    {
        is.getline(buffer,LINEMAX);
        realloc(filelist,sizeof(char**) * (filecount + 1));
        filelist[filecount] = (char*) malloc(std::strlen(buffer) + 1);
        std::strcpy(filelist[filecount],buffer);
        filecount++;
    }

    return 0;
}
</code></pre>
