AP_HAL: use calloc in preferance to malloc

This commit is contained in:
Andrew Tridgell 2018-01-17 08:10:23 +11:00
parent f6138e3c91
commit 3f5534eed5

View File

@ -5,7 +5,7 @@
ByteBuffer::ByteBuffer(uint32_t _size) ByteBuffer::ByteBuffer(uint32_t _size)
{ {
buf = (uint8_t*)malloc(_size); buf = (uint8_t*)calloc(1, _size);
size = buf ? _size : 0; size = buf ? _size : 0;
} }
@ -22,7 +22,7 @@ bool ByteBuffer::set_size(uint32_t _size)
head = tail = 0; head = tail = 0;
if (_size != size) { if (_size != size) {
free(buf); free(buf);
buf = (uint8_t*)malloc(_size); buf = (uint8_t*)calloc(1, _size);
if (!buf) { if (!buf) {
size = 0; size = 0;
return false; return false;