From cd20b208d0317ae25ecc864c321f0488301ac4c8 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 2 Nov 2020 19:07:03 +0100 Subject: [PATCH] bigbuf calloc ftc where the memory is set to zero before --- armsrc/BigBuf.c | 10 ++++++++++ armsrc/BigBuf.h | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/armsrc/BigBuf.c b/armsrc/BigBuf.c index c7c370047..80104156d 100644 --- a/armsrc/BigBuf.c +++ b/armsrc/BigBuf.c @@ -129,6 +129,16 @@ uint8_t *BigBuf_malloc(uint16_t chunksize) { return (uint8_t *)BigBuf + s_bigbuf_hi; } +// allocate a chunk of memory from BigBuf, and returns a pointer to it. +// sets the memory to zero +uint8_t *BigBuf_calloc(uint16_t chunksize) { + uint8_t *mem = BigBuf_malloc(chunksize); + if (mem != NULL) { + memset(mem, 0x00, chunksize); + } + return mem; +} + // free ALL allocated chunks. The whole BigBuf is available for traces or samples again. void BigBuf_free(void) { s_bigbuf_hi = s_bigbuf_size; diff --git a/armsrc/BigBuf.h b/armsrc/BigBuf.h index bf6600e1e..ff444f3c8 100644 --- a/armsrc/BigBuf.h +++ b/armsrc/BigBuf.h @@ -34,6 +34,7 @@ void BigBuf_Clear_ext(bool verbose); void BigBuf_Clear_keep_EM(void); void BigBuf_Clear_EM(void); uint8_t *BigBuf_malloc(uint16_t); +uint8_t *BigBuf_calloc(uint16_t); void BigBuf_free(void); void BigBuf_free_keep_EM(void); void BigBuf_print_status(void); @@ -46,10 +47,8 @@ bool get_tracing(void); bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_start, uint32_t timestamp_end, uint8_t *parity, bool readerToTag); bool LogTrace_ISO15693(const uint8_t *bytes, uint16_t len, uint32_t ts_start, uint32_t ts_end, uint8_t *parity, bool reader2tag); - uint8_t emlSet(uint8_t *data, uint32_t offset, uint32_t length); - typedef struct { int max; int bit;