Skip to content

Commit

Permalink
cgen: string buffer fix
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed May 25, 2020
1 parent b0cfd3f commit 0f92800
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions vlib/v/gen/cgen.v
Expand Up @@ -2489,6 +2489,11 @@ fn (mut g Gen) write_init_function() {
}
fn_vinit_start_pos := g.out.len
g.writeln('void _vinit() {')
if g.pref.autofree {
// Pre-allocate the string buffer
// TODO make it configurable
g.writeln('g_str_buf = malloc(1024 * 1000);')
}
g.writeln('\tbuiltin_init();')
g.writeln('\tvinit_string_literals();')
g.writeln(g.inits.str())
Expand Down
3 changes: 2 additions & 1 deletion vlib/v/gen/cheaders.v
Expand Up @@ -240,7 +240,8 @@ void* g_live_info = NULL;
#endif
//================================== GLOBALS =================================*/
byte g_str_buf[1024];
//byte g_str_buf[1024];
byte* g_str_buf;
int load_so(byteptr);
void reload_so();
void _vinit();
Expand Down

0 comments on commit 0f92800

Please sign in to comment.