adding c++ support and adding yyinit/yydeinit to fix memory leaks #1

Open
wants to merge 2 commits into
from

Projects

None yet

3 participants

@onnlucky

hi,

thought you might be interested

properly cast void* to target pointer type (a c vs c++ difference)
added yyinit that zeroes GREG struct
added yydeinit that frees GREG->buf etc.
fixed yyfree by using yydeinit
added make test target
refreshed greg.c

onnlucky added some commits Mar 29, 2011
@onnlucky onnlucky make C++ compileable
implicit void casting not allowed
add const to yymatchString
e531e09
@onnlucky onnlucky add yyinit yydeinit and pass YY_INPUT G->data
fixes memory leaks
add make test to build sample and fix sample using new init/deinit
updated greg.g and greg.c
2dd25c7
@nddrylliog
ooc language member

Hey, awesome :) Merging right now, I've been using it lately and it's great to see some support :)

@tokuhirom

One of the biggest issue around C++ is G->vals is using malloc/realloc/free.
If you want to support C++, you need switching to std::vector or something.

@tokuhirom

Without switching to vector or some containers, you can't use STL containers as YYSTYPE.

@nddrylliog
ooc language member

@tokuhirom Having C++ support would be nice - but I definitely don't want to lose C support.

@tokuhirom

You can support both language by command line options like greg -p foo.y :)

@nddrylliog
ooc language member

I don't think that's a big deal - you can still compile the C code as a module and use it from C++..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment