diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-12-21 14:30:11 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-12-21 14:30:11 -0500 |
| commit | 86a08a38a8a60b6a0de0da62a5d3fa843f6db71f (patch) | |
| tree | 2e7649bb00f6ceed8f6c087de573c873cf753789 | |
| parent | 1836d095f88ff83d9499c1e979362352a1fa400b (diff) | |
Fix empty allocation
| -rw-r--r-- | .github/workflows/release.yml | 6 | ||||
| -rw-r--r-- | 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}; \ }) |
