In my Apache module, which is built in C++, I uses strings, vectors, and the related when attempting to provide functionality to my module.
My concern is that I am not using the Apache memory pool and that the program is going to segfault along the way, but at the same time I having difficulty with certain task such as this:
static void parseSTR(char *input, const char *sep, int &count, apr_table_t *&values, apr_pool_t *mp)
{
char *part, *next;
if (isStrNull(input))
return;
count = 1;
part = apr_strtok(input, sep, &next);
while (part) {
apr_table_set(values, apr_itoa(mp, count), part);
part = apr_strtok(NULL, sep, &next);
count++;
}
}
which I am using a delimited string parser to parse URLs and domain names. Surely there is a more efficient way to provide this functionality. I am using the apr_table structure to contain each part, I know I could use an apr_array_header, but....
So I would like to know:
- Could I use Boost to provide the missing functionality SAFELY?
- Will I run into memory clashes because I am not using the pool memory?
- For string, vector, and etc that free their own memory, is this a problem laying in wait?
I did search for this issue, but the other issues do not seem to be the same.