提交 03ee47ae 编写于 作者: P Peter Malone 提交者: Michael S. Tsirkin

ringtest: ring.c malloc & memset to calloc

Code cleanup change - moving from malloc & memset to calloc.
Signed-off-by: NPeter Malone <peter.malone@gmail.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
上级 0063e8bb
......@@ -84,12 +84,11 @@ void alloc_ring(void)
perror("Unable to allocate ring buffer.\n");
exit(3);
}
event = malloc(sizeof *event);
event = calloc(1, sizeof(*event));
if (!event) {
perror("Unable to allocate event buffer.\n");
exit(3);
}
memset(event, 0, sizeof *event);
guest.avail_idx = 0;
guest.kicked_avail_idx = -1;
guest.last_used_idx = 0;
......@@ -102,12 +101,11 @@ void alloc_ring(void)
ring[i] = desc;
}
guest.num_free = ring_size;
data = malloc(ring_size * sizeof *data);
data = calloc(ring_size, sizeof(*data));
if (!data) {
perror("Unable to allocate data buffer.\n");
exit(3);
}
memset(data, 0, ring_size * sizeof *data);
}
/* guest side */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册