From 86a08a38a8a60b6a0de0da62a5d3fa843f6db71f Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 21 Dec 2025 14:30:11 -0500 Subject: Fix empty allocation --- .github/workflows/release.yml | 6 +++--- src/stdlib/lists.h | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 234d0685..d153774f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: - name: Build run: | make clean - make + make -j - name: Package run: | @@ -58,7 +58,7 @@ jobs: - name: Build run: | make clean - make + make -j - name: Package run: | @@ -87,7 +87,7 @@ jobs: - name: Build run: | make clean - make + make -j - name: Package run: | diff --git a/src/stdlib/lists.h b/src/stdlib/lists.h index 457fed52..6a0a1d43 100644 --- a/src/stdlib/lists.h +++ b/src/stdlib/lists.h @@ -61,7 +61,8 @@ extern char _EMPTY_LIST_SENTINEL; t items[] = {__VA_ARGS__}; \ (List_t){.length = sizeof(items) / sizeof(items[0]), \ .stride = (int64_t)&items[1] - (int64_t)&items[0], \ - .data = memcpy(GC_MALLOC(sizeof(items)), items, sizeof(items)), \ + .data = sizeof(items) == 0 ? &_EMPTY_LIST_SENTINEL \ + : memcpy(GC_MALLOC(sizeof(items)), items, sizeof(items)), \ .atomic = 0, \ .data_refcount = 0}; \ }) @@ -70,7 +71,7 @@ extern char _EMPTY_LIST_SENTINEL; t items[N] = {__VA_ARGS__}; \ (List_t){.length = N, \ .stride = (int64_t)&items[1] - (int64_t)&items[0], \ - .data = memcpy(GC_MALLOC(sizeof(items)), items, sizeof(items)), \ + .data = N == 0 ? &_EMPTY_LIST_SENTINEL : memcpy(GC_MALLOC(sizeof(items)), items, sizeof(items)), \ .atomic = 0, \ .data_refcount = 0}; \ }) -- cgit v1.2.3