# sema: add \`prev\` to ValueArena to allow freeing previous arenas when new ones are created during re-analysis · gitcafe/zig

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

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

Visibility: public

Requested revision: 15dafd16e65a8cd8ea434f0b4783f08875254cd4

Requested commit: 15dafd16e65a8cd8ea434f0b4783f08875254cd4

Commit: 15dafd16e65a8cd8ea434f0b4783f08875254cd4

Tree: 3d375de60cb43e1a353994cc101f4efb3bfc023e

Author: kcbanner

Committer: kcbanner

## Message

```
sema: add `prev` to ValueArena to allow freeing previous arenas when new ones are created during re-analysis

In semaDecl, it was possible for a new ArenaAllocators state to replace an existing one that
hadn't been freed yet. Instead of the ref_count (which was made redundant by adding
the allocator parameter to `release`), I now store a pointer to the previous arena, if one exists.

This allows a recursive deinit to happen when the last arena created is destroyed.

```

## Parents

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

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