diff options
| author | John Hawthorn <john@hawthorn.email> | 2026-04-12 00:12:00 -0700 |
|---|---|---|
| committer | John Hawthorn <john@hawthorn.email> | 2026-04-13 08:46:06 -0700 |
| commit | 3a90afd1d07b9403e5f52db5608e22930faff376 (patch) | |
| tree | 70728914e32ca95ef85b35391e22f80981e616b8 | |
| parent | 1ffe16ce6e8f9c45f14e5a72bc4c6edb02222073 (diff) | |
Avoid atomic exchange in rb_free_tmp_buffer
Usually RB_ALLOCV_N uses alloca for small allocations, and in that case
the value is 0, and we should not need to atomic exchange it back to 0.
I'm actually not sure why we need atomic operations here anyways.
| -rw-r--r-- | imemo.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -89,6 +89,7 @@ rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t size, size_t cnt) void rb_free_tmp_buffer(volatile VALUE *store) { + if (!*store) return; rb_imemo_tmpbuf_t *s = (rb_imemo_tmpbuf_t*)ATOMIC_VALUE_EXCHANGE(*store, 0); if (s) { void *ptr = ATOMIC_PTR_EXCHANGE(s->ptr, 0); |
