Regular expressions, C++ kai linux

Dimitris Stasinopoulos dimitris at linea.gr
Mon Jun 24 23:36:01 EEST 2002


On Δευ 24 Ιουν 2002 22:14, Nikos Mavroyanopoulos wrote:
> On Mon, Jun 24, 2002 at 09:39:49PM +0300, Dimitris Stasinopoulos wrote:
> > Paides xaireto()
> > Proekipse ena "endiaferon" provlima.
> >
> > Mesa se kodika C++ prepei na xrisimopoiiso regular expressions. Ara
> > prepei na kaleso tin regcomp(). Me to pou to kano omos, amesos pairno
> > SIGSEGV, kai afto dioti i regcomp() kanei allocate kapoion xoro gia na
> > kanei compile tin regular expression, kai profanos aftos o xoros ginetai
> > allocated me kapoia apo tis *alloc() functions tis glibc.
> > Omos, epeidi o "new" operator tis C++ kai oi *alloc den prepei na paizoun
> > pote mesa ston idio kodika, pairno to anaferthen SIGSEGV.
>
> Τι ακριβώς απαγορεύει να μην παιζει η malloc μαζί με την new?

Se arketa projects pio palia, opou ipirxe anameiksi malloc kai new (polles 
fores kai xoris new, arkei na eftiaxna kapoio object kapou, akoma kai sto 
local scope mias function) arga i grigora emfanizotan sigsegv. Me to estelna 
to zevgaraki malloc()/free() gia broubes, kai ebaza stis theseis tous ebaza 
new/delete, to provlima eksafanizotan. Me backtrace ston gdb, to provlima 
ebgaine stin glibc, sigkekrimena stin chunk_free (). Px apo pio palio post:

Program received signal SIGSEGV, Segmentation fault.
0x4010e36d in chunk_free () from /lib/libc.so.6
(gdb) bt
#0  0x4010e36d in chunk_free () from /lib/libc.so.6

> Το μόνο κακό είναι να κάνεις delete πραγματα που δεσμεύτηκαν με την
> malloc. Το καλύτερο είναι πάντως να δείς με κάποιο debugger που
> πήρες το αναφερθέν sigsegv.

Ennoeitai oti den kano delete ta malloc()'ed, kai free() ta new'ed.

To proigoumeno sxetiko post pou eixe anaferthei to thema einai edo:

http://lists.hellug.gr/pipermail/linux-greek-users/2002-February/098750.html

> ΥΓ. έβαλες τα includes κλπ κλπ της C μέσα σε extern "C" {}?

Eeerrrr....oops?

-- 
Dimitris Stasinopoulos

I am but a small signature
At the down down of the writing
If you don't read me
It will become the come and see.



More information about the Linux-greek-users mailing list