# arena_allocator/reset: avoid zero-capacity allocations · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/89bd29a9058eabf23c735761c49809bb63a68842)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 89bd29a9058eabf23c735761c49809bb63a68842

Requested commit: 89bd29a9058eabf23c735761c49809bb63a68842

Commit: 89bd29a9058eabf23c735761c49809bb63a68842

Tree: ff4248f657d3a71f335f0648dc8df947ef90e253

Author: Erik Arvstedt

Committer: Erik Arvstedt

## Message

```
arena_allocator/reset: avoid zero-capacity allocations

1. When the arena is already empty, resetting with `retain_capacity` no longer
   results in allocating a buffer with zero capacity.
   This behavior was previously intended by the `(current_capacity == 0)` check,
   but wasn't correctly implemented.

2. Resetting with `.{ .retain_with_limit = 0 }` is now equivalent to
   `free_all` and a new buffer with zero capacity is no longer created.
   This is a useful side-effect of the above fixes.

```

## Parents

- [5d3c8f4913884a4503e9f183e471b6090bb5bc92](https://git.cafe/gitcafe/zig/commit/5d3c8f4913884a4503e9f183e471b6090bb5bc92?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/89bd29a9058eabf23c735761c49809bb63a68842?format=markdown)
