diff options
| author | Tetralux <tetralux@teknik.io> | 2020-01-03 10:40:45 +0000 |
|---|---|---|
| committer | Tetralux <tetralux@teknik.io> | 2020-01-03 10:40:45 +0000 |
| commit | b32ef9e47be90a49010246359475130718dd0af8 (patch) | |
| tree | 4767723d6d6de0ae78cf6c57206551d483ff48ac /src/check_type.cpp | |
| parent | b8324b0776d0d8d653e44c9f7876d01509b60e77 (diff) | |
Fix make and reserve
- Set the allocator, even if memory allocation fails.
Right now it doesn't, which means that if allocation fails, it'll use
the context allocator instead. This memory will be leaked if the user
doesn't understand that this happened.
- Only set len and cap of the array returned from make iif the memory allocation
succeeded.
This means that reserve will return false if you do this:
```
a := make([dynamic]int, failing_allocator);
if !reserve(&a, 5) do return; // or whatever indicates failure
```
Diffstat (limited to 'src/check_type.cpp')
0 files changed, 0 insertions, 0 deletions