From b29b7bfe32224b37637f02702dba818292b69884 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 4 Apr 2022 20:34:49 -0400 Subject: [PATCH 1/2] Free ringbuf buffer by relying on gc, not gc_free() --- py/ringbuf.c | 7 ++----- py/ringbuf.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/py/ringbuf.c b/py/ringbuf.c index 72e164946ae5b..fe47b50068b65 100644 --- a/py/ringbuf.c +++ b/py/ringbuf.c @@ -28,7 +28,6 @@ #include "ringbuf.h" bool ringbuf_init(ringbuf_t *r, uint8_t *buf, size_t capacity) { - r->heap = false; r->buf = buf; r->size = capacity; r->iget = r->iput = 0; @@ -40,7 +39,6 @@ bool ringbuf_init(ringbuf_t *r, uint8_t *buf, size_t capacity) { // size of the buffer is one greater than that, due to how the buffer // handles empty and full statuses. bool ringbuf_alloc(ringbuf_t *r, size_t capacity, bool long_lived) { - r->heap = true; r->buf = gc_alloc(capacity + 1, false, long_lived); r->size = capacity + 1; r->iget = r->iput = 0; @@ -48,9 +46,8 @@ bool ringbuf_alloc(ringbuf_t *r, size_t capacity, bool long_lived) { } void ringbuf_free(ringbuf_t *r) { - if (r->heap) { - gc_free(r->buf); - } + // Free buf by letting gc take care of it. If the VM has finished already, + // this will be safe. r->buf = (uint8_t *)NULL; r->size = 0; ringbuf_clear(r); diff --git a/py/ringbuf.h b/py/ringbuf.h index 8f7e7b1760598..d868eff1e40d6 100644 --- a/py/ringbuf.h +++ b/py/ringbuf.h @@ -37,7 +37,6 @@ typedef struct _ringbuf_t { uint32_t size; uint32_t iget; uint32_t iput; - bool heap; } ringbuf_t; // Note that the capacity of the buffer is N-1! From 70add5277505cbd388729ba2ae8a055ebd21f717 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 4 Apr 2022 22:11:58 -0400 Subject: [PATCH 2/2] advance espressif CI cache key --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b9592687198f..6df3935555400 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -400,7 +400,7 @@ jobs: id: idf-cache with: path: ${{ github.workspace }}/.idf_tools - key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/espressif/esp-idf/HEAD') }}-20210923 + key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/espressif/esp-idf/HEAD') }}-20220404 - name: Clone IDF submodules run: | (cd $IDF_PATH && git submodule update --init)