I was wondering if anyone had any suggestions on where I could go to
get some advice on a milter I wrote. It seems to be leaking memory
and I am not sure why. Please understand this is my first project in
c and I have also used it in learning c. Previous to this I have only
written a small hand full of programs no more than about 30 lines each
in c.
If any of you would like to take a look the source code is located at
http://www.fletchcom.com/spamhammilt-0.1.tar.gz and thank you in
advance for any help and pointers, no pun intended, with this.
Thanks
Steven
have you tried tek-tips or experts-exchange ?
stevfl...@gmail.com wrote:
I'm not an expert programmer, but it looks very good, with all kind of error
handling, clearing memory and so on.
But what definitively is wrong is the regexp: the regex_t structure contains
a pointer to a character array which is filled by regcomp.... and never
freed. You have to add "regfree(&rx)" and to be sure that it is called
always:
err = regcomp ( &rx,expr,REG_EXTENDED|REG_ICASE|REG_NOSUB );
regfree(&rx);
Nevertheless, on my system the program crashes under extreme load, so there
is another thing not 100% ok, but I'm do not know what.....
Test:
cat /etc/profile | mail -s "test" username in a loop over 1000 times,
which may load the system more then ever in normal use....
Good luck!
H.Janssen
Alkmaar
The Netherlands
Sorry,
> err = regcomp ( &rx,expr,REG_EXTENDED|REG_ICASE|REG_NOSUB );
> regfree(&rx);
>
>
Of course, regfree should not be directly behind regcomp,
because in that case regexec will fail,
but behind regexec().
I only do not know whether you must call regfree() in case
regcomp() returns an error, that's not clear from the documentation.
Thank you very much for the review and the idea about the regex. I'll
give it a try and continue digging for leaks.
Steven Fletcher