examples: use vcalloc

pull/3937/head
Alexander Medvednikov 2020-03-04 17:28:05 +01:00
parent c203a744fe
commit 59a65d757b
2 changed files with 80 additions and 80 deletions

View File

@ -46,8 +46,8 @@ fn new_automaton(f [][]int) Automaton {
maxx = f[y].len maxx = f[y].len
} }
} }
field := &A2D{ maxx: maxx maxy: maxy data: &int( calloc( sizeof(int) * maxy * maxx ) ) } field := &A2D{ maxx: maxx maxy: maxy data: &int( vcalloc( sizeof(int) * maxy * maxx ) ) }
new_field := &A2D{ maxx: maxx maxy: maxy data: &int( calloc( sizeof(int) * maxy * maxx ) ) } new_field := &A2D{ maxx: maxx maxy: maxy data: &int( vcalloc( sizeof(int) * maxy * maxx ) ) }
for y in 0..field.maxy { for y in 0..field.maxy {
for x in 0..field.maxx { for x in 0..field.maxx {
field.set( x, y, f[y][x] ) field.set( x, y, f[y][x] )

View File

@ -94,7 +94,7 @@ fn new_image(w int, h int) Image {
return Image{ return Image{
width: w, width: w,
height: h, height: h,
data: &Vec(calloc(sizeof(Vec)*w*h)) data: &Vec(vcalloc(sizeof(Vec)*w*h))
} }
} }