examples: use vcalloc
parent
c203a744fe
commit
59a65d757b
|
@ -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] )
|
||||||
|
|
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue