Skip to content
This repository has been archived by the owner on Jul 26, 2018. It is now read-only.

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

onnlucky
Copy link

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

implicit void casting not allowed
add const to yymatchString
fixes memory leaks
add make test to build sample and fix sample using new init/deinit
updated greg.g and greg.c
@nddrylliog
Copy link
Member

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

@tokuhirom
Copy link

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
Copy link

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

@nddrylliog
Copy link
Member

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

@tokuhirom
Copy link

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

@nddrylliog
Copy link
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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants