From 3f5534eed5337536123d60faf962537f70d18033 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 17 Jan 2018 08:10:23 +1100 Subject: [PATCH] AP_HAL: use calloc in preferance to malloc --- libraries/AP_HAL/utility/RingBuffer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/AP_HAL/utility/RingBuffer.cpp b/libraries/AP_HAL/utility/RingBuffer.cpp index 2c3ea87b02..f3b3bee22f 100644 --- a/libraries/AP_HAL/utility/RingBuffer.cpp +++ b/libraries/AP_HAL/utility/RingBuffer.cpp @@ -5,7 +5,7 @@ ByteBuffer::ByteBuffer(uint32_t _size) { - buf = (uint8_t*)malloc(_size); + buf = (uint8_t*)calloc(1, _size); size = buf ? _size : 0; } @@ -22,7 +22,7 @@ bool ByteBuffer::set_size(uint32_t _size) head = tail = 0; if (_size != size) { free(buf); - buf = (uint8_t*)malloc(_size); + buf = (uint8_t*)calloc(1, _size); if (!buf) { size = 0; return false;