# std: enable FailingAllocator to fail on resize · gitcafe/zig

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

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

Visibility: public

Requested revision: cab9da35bd65c81e8efbac3a6c970ce17627e4c7

Requested commit: cab9da35bd65c81e8efbac3a6c970ce17627e4c7

Commit: cab9da35bd65c81e8efbac3a6c970ce17627e4c7

Tree: 6ffbf71d4d44490e554c355cc853fa0671dd3a2e

Author: Gregory Anders

Committer: Veikka Tuominen

## Message

```
std: enable FailingAllocator to fail on resize

Now that allocator.resize() is allowed to fail, programs may wish to
test code paths that handle resize() failure. The simplest way to do
this now is to replace the vtable of the testing allocator with one
that uses Allocator.noResize for the 'resize' function pointer.

An alternative way to support this testing capability is to augment the
FailingAllocator (which is already useful for testing allocation failure
scenarios) to intentionally fail on calls to resize(). To do this, add a
'resize_fail_index' parameter to the FailingAllocator that causes
resize() to fail after the given number of calls.

```

## Parents

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

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