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

wants to merge 2 commits into


None yet

3 participants



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
@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
ooc language member

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


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.


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

ooc language member

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


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

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