about pcre regex lib

M

mainland

I use prce to match string. I define a pcre struct point, then
compile, pass pcre struct point to 'pcre_compile'.

When complete, Is it necessary to use 'pcre_free' to free pcre struct
point.

example:

.......

pcre *re;
const char* errorptr;
int erroroffset;

re = pcre_compile ( "pattern", 0 , &errorptr, &erroroffset, 0);

..... do samething .....

if ( re != NULL )
{
pcre_free ( re );
re = NULL;
}

.......

And, Is 'pcre_free' thread safe ???
 
F

Flash Gordon

mainland said:
I use prce to match string. I define a pcre struct point, then
compile, pass pcre struct point to 'pcre_compile'.

When complete, Is it necessary to use 'pcre_free' to free pcre struct
point.

<snip>

You need to ask somewhere that pcre is topical (after reading the man
pages and other documentation). We only deal with standard C, not the
thousands 3rd party of libraries written in C or used from C. Also, I
suggest you read the last link in my sig for more information about this
group.
 
J

Jack Klein

I use prce to match string. I define a pcre struct point, then
compile, pass pcre struct point to 'pcre_compile'.

Third party libraries that are not part of the standard C language are
off-topic here.
When complete, Is it necessary to use 'pcre_free' to free pcre struct
point.

You need to ask in a group or list that supports this library, if this
information is not in the documentation. You did read the
documentation?
example:

......

pcre *re;
const char* errorptr;
int erroroffset;

re = pcre_compile ( "pattern", 0 , &errorptr, &erroroffset, 0);

.... do samething .....

if ( re != NULL )
{
pcre_free ( re );
re = NULL;
}

......

And, Is 'pcre_free' thread safe ???

The C language does not define or support threads in any way, shape,
or form. Again, you need to consult the library's documentation, or
ask in a newsgroup or mailing list that supports it. Or just
possibly, in a group that supports your compiler/OS combination.
 
J

jacob navia

mainland said:
I use prce to match string. I define a pcre struct point, then
compile, pass pcre struct point to 'pcre_compile'.

When complete, Is it necessary to use 'pcre_free' to free pcre struct
point.

example:

......

pcre *re;
const char* errorptr;
int erroroffset;

re = pcre_compile ( "pattern", 0 , &errorptr, &erroroffset, 0);

.... do samething .....

if ( re != NULL )
{
pcre_free ( re );
re = NULL;
}

......

And, Is 'pcre_free' thread safe ???

Yes, you should call pcre_free_substring or pcre_free (re)
Since pcre_free can be changed by the user of the library,
your question has no sense. It depends which function is
pcre free.

lcc-win32 offers pcre.lib as standard, and by default there pcre_free is
the function free() from the standard library, that is thread safe in
the implementation used by lcc-win32. I can't say anything for other
compilers but I would suspect that most of the fre() implementations
are thread safe.
 
J

jacob navia

Jack said:
Third party libraries that are not part of the standard C language are
off-topic here.

Maybe, pcre (stands for Perl compatible regular expressions)
is a very popular library, and I consider that it is not off topic

Your opinion may differ of course.
The C language does not define or support threads in any way, shape,
or form. Again, you need to consult the library's documentation, or
ask in a newsgroup or mailing list that supports it. Or just
possibly, in a group that supports your compiler/OS combination.

I think threads (that are now a POSIX standard and also present in
windows) are a "fact of life". You can't ignore them in modern programming

jacob
 
R

Richard Heathfield

jacob navia said:
Jack Klein wrote:


I think threads (that are now a POSIX standard and also present in
windows) are a "fact of life". You can't ignore them in modern programming

That may or may not be true, but what is certainly true is that C itself
does not provide language or library support for threads, and so the
appropriate place to discuss them is in a newsgroup where implementations
that /do/ support them are topical.
 
F

Flash Gordon

jacob said:
Maybe, pcre (stands for Perl compatible regular expressions)
is a very popular library, and I consider that it is not off topic

Your opinion may differ of course.

I do disagree, and I say that as someone who does use pcre.
I think threads (that are now a POSIX standard and also present in
windows) are a "fact of life". You can't ignore them in modern programming

That's strange, I've managed to successfully ignore threads a lot of the
time. Mainly because lots of applications don't need threads, but also
because not all of the systems I program for use the same threading model.
 
W

websnarf

mainland said:
I use prce to match string. I define a pcre struct point, then
compile, pass pcre struct point to 'pcre_compile'.

When complete, Is it necessary to use 'pcre_free' to free pcre struct
point.

Good question. The PCRE documentation does not describe how to free
the resources used to compile a regex. It *SEEMS* as though this is
the case; looking through the sources of pcre briefly it does look like
he's doing a lot of "struct hack"-like things to place the variable
length data at the very end of the header (i.e., its quite possible
that all the stuff needed to retain the compiled regex has be rammed
into a single allocation obtained via pcre_malloc().)

I have emailed the author of pcre personally about similar issues, and
he has responded. So I think you might like to try your luck doing
that as well.
And, Is 'pcre_free' thread safe ???

pcre_free is a global function pointer that is initialized to be
free(). It is not declared as volatile or anything like that. So
using the function on the other end is supposed to be thread safe (this
is documented) however obviously the mere act of *setting* the
pcre_free function might itself not be thread safe. This is probably
not a big deal, since you would only want to set that function once
before you launched any threads that might use it.
 
B

bbq

[newblue@bEyoOo ~]$ cat Jack Klein
Third party libraries that are not part of the standard C language are
off-topic here.

Yes, I see, but I can't find a group to talk about pcre libraries or
third party libraries.
You need to ask in a group or list that supports this library, if this
information is not in the documentation. You did read the
documentation?

Yes, I did. But I can't find any information to deal with this problem.
The C language does not define or support threads in any way, shape,
or form. Again, you need to consult the library's documentation, or
ask in a newsgroup or mailing list that supports it. Or just
possibly, in a group that supports your compiler/OS combination.

Thank you!
 
B

bbq

[newblue@bEyoOo ~]$ cat Flash Gordon
You need to ask somewhere that pcre is topical (after reading the man
pages and other documentation). We only deal with standard C, not the
thousands 3rd party of libraries written in C or used from C. Also, I
suggest you read the last link in my sig for more information about
this group.

I know pcre written in C, and I think that somebody might use this
libraries.

I sorry to the mistake to post this question here.
 
B

bbq

[newblue@bEyoOo ~]$ cat jacob navia
Yes, you should call pcre_free_substring or pcre_free (re)
Since pcre_free can be changed by the user of the library,
your question has no sense. It depends which function is
pcre free.

lcc-win32 offers pcre.lib as standard, and by default there pcre_free is
the function free() from the standard library, that is thread safe in
the implementation used by lcc-win32. I can't say anything for other
compilers but I would suspect that most of the fre() implementations
are thread safe.

Thank you!!
 
B

bbq

[newblue@bEyoOo ~]$ cat (e-mail address removed)
Good question. The PCRE documentation does not describe how to free
the resources used to compile a regex. It *SEEMS* as though this is
the case; looking through the sources of pcre briefly it does look like
he's doing a lot of "struct hack"-like things to place the variable
length data at the very end of the header (i.e., its quite possible
that all the stuff needed to retain the compiled regex has be rammed
into a single allocation obtained via pcre_malloc().)

I have emailed the author of pcre personally about similar issues, and
he has responded. So I think you might like to try your luck doing
that as well.

Thank you!!
pcre_free is a global function pointer that is initialized to be
free(). It is not declared as volatile or anything like that. So
using the function on the other end is supposed to be thread safe (this
is documented) however obviously the mere act of *setting* the
pcre_free function might itself not be thread safe. This is probably
not a big deal, since you would only want to set that function once
before you launched any threads that might use it.

Thanks for you help , I see.
 
M

Mark McIntyre

[newblue@bEyoOo ~]$ cat Jack Klein
Third party libraries that are not part of the standard C language are
off-topic here.

Yes, I see, but I can't find a group to talk about pcre libraries or
third party libraries.

I can't find anywhere to talk about my children's paintings. That
doesn't make CLC the right place to raise it.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
R

Richard Bos

bbq said:
[newblue@bEyoOo ~]$ cat Jack Klein
Third party libraries that are not part of the standard C language are
off-topic here.

Yes, I see, but I can't find a group to talk about pcre libraries or
third party libraries.

If the florist in your home town is closed, do you go to the greengrocer
to buy tulips?

Richard
 
C

Chris McDonald

[newblue@bEyoOo ~]$ cat Jack Klein
Third party libraries that are not part of the standard C language are
off-topic here.

Yes, I see, but I can't find a group to talk about pcre libraries or
third party libraries.
If the florist in your home town is closed, do you go to the greengrocer
to buy tulips?

In my suburb, that would be a possible, and successful, course of action.
Replacing the greengrocer with a plumber would be less successful, though.
 
K

Kenny McCormack

<snip>

You need to ask somewhere that pcre is topical (after reading the man
pages and other documentation). We only deal with standard C, not the
thousands 3rd party of libraries written in C or used from C. Also, I
suggest you read the last link in my sig for more information about this
group.

This is good advice. See below for more useful links that will help you
understand the nut-house that is clc. And, as Ed Morton says, make sure
you've had your rabies shot.

Useful clc-related links:

http://en.wikipedia.org/wiki/Clique
http://en.wikipedia.org/wiki/Aspergers
http://en.wikipedia.org/wiki/C_programming_language
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top