[TRE-general] Memory leak?

Christian Wieninger cwieninger at gmx.de
Thu Jan 11 21:46:23 EET 2007


Hi,

I'm new to TRE, so please be patient and excuse my english ;-)

I have a strange problem with this piece of code that is used to find
similar text in a huge text database:

...
#ifdef HAVE_LIBTRE
#include <tre/regex.h>
...
	    regex_t re;
	    if ( 0 == regncomp(&re, searchText, strlen(searchText), REG_LITERAL) )
	    {
		regamatch_t match;
		memset(&match, 0, sizeof(match));
		regaparams_t params;
		regaparams_default(&params);
		params.max_cost = tolerance;
		bool found = (reganexec( &re, szTest, strlen(szTest), &match, params,
0) == 0);
		return found;
	    }
	    return false;	
#else
...

'tolerance' is an int between 1 and 99.
'searchText' is a simple text to be searched in 'szTest'.
It works and is called many thousand times. But it seems that there is
any memory leak eating up all memory after some time. Is there anything
wrong with my code?

Another problem: Perhaps you wonder why I'm using the 'n' versions like
regncomp instead of regcomp. If I use the regular ones I get a segfault
when calling regaexec, because of a value of 0x90 in the internal tnfa
pointer. It seems that any standard regex library is used in this case
instead of TRE, although I link with '-ltre'. I have compiled TRE
without ABI support.

Any idea?

Thanks,

Christian


More information about the TRE-general mailing list