goccy / p5-Compiler-Lexer

Lexical Analyzer for Perl5
Other
46 stars 17 forks source link

Support the function to specify extra memory size to allocate in advance #54

Closed moznion closed 9 years ago

moznion commented 9 years ago

ref: #53

goccy commented 9 years ago

Thanks for reporting. But this behavior is not a specification. Therefore, It do not need to switch by options.

Simply, what about the following code ?

Compiler_lexer.cpp L15-16

+ static const int EXTEND_BUFFER_SIZE = 16; // this parameter is needed to correspond #53
- script_size = strlen(script) + 1;
+ script_size = strlen(script) + 1 + EXTEND_BUFFER_SIZE;
moznion commented 9 years ago

Well, how do we deal with this problem if memory size is shorter than hard-coded EXTEND_BUFFER_SIZE?

goccy commented 9 years ago

I modified the above code and created PR #56. Please review this code > @moznion

Well, how do we deal with this problem if memory size is shorter than hard-coded EXTEND_BUFFER_SIZE?

Is it problem ?

moznion commented 9 years ago

Yes, if target code occupies memory which overs the maximum size then we cannot handle it.

Example for the above case;

s///;s///;s///;s///;s///;s///;s///;s///;s///;s///;

If this code is evaluated, it will occur SEGV. This is silly case, but we cannot handle it indeed.

So I wish to configure the size of extended memory.

goccy commented 9 years ago

If will support the above code, it must check buffer size enough or not for each tokens. If there is a need, I will support. This feature should not be supported as option.

moznion commented 9 years ago

Okay, I understood. There is a necessity, I think.

I've closed this pull request. Please apply #56.