mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
examples: use vcalloc
This commit is contained in:
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user