March 10th, 2009, 08:12 AM
How to regex_t variable in a map?
I am trying to create a map in C++ which will have the regular expression and the corresponding compiled regular form returned by regcomp. It will be something like this:
map <string, regex_t> my_var;
In the startup process we read the regular expressions and store corresponding regex_t variable value in the map. regex_t variable is something like this:
reslt = regcomp(&re, regex_string, REG_EXTENDED|REG_NOSUB);
then we do:
In other file we use this map to read the re and pass it on to regexec.
It compiles well. But on running we get coredump.
We are yet to call regfree in the startup process to free memory allocated by regcomp. I guess issues will be there also since it did not work in my test program. Good old segmentation fault.
Read somewhere on the net that we cant copy regex_t since its an opaque and cant just copy it.
Any suggestions friends?
March 10th, 2009, 05:10 PM
What is your regex question?