aboutsummaryrefslogtreecommitdiff
path: root/lib/std/heap.zig
AgeCommit message (Collapse)Author
2022-08-22stage2+stage1: remove type parameter from bit builtinsVeikka Tuominen
Closes #12529 Closes #12511 Closes #6835
2022-06-03std: update tests to stage2 semanticsVeikka Tuominen
2022-05-17stage2: fix pointer arithmetic result typeAndrew Kelley
This makes it so the result of doing pointer arithmetic creates a new pointer type that has adjusted alignment.
2022-05-01std.heap: Fix typor00ster
2022-04-27std: replace usage of std.meta.bitCount() with @bitSizeOf()Isaac Freund
2021-12-19stage1, stage2: rename c_void to anyopaque (#10316)Isaac Freund
zig fmt now replaces c_void with anyopaque to make updating code easy.
2021-11-30allocgate: change resize to return optional instead of errorLee Cannon
2021-11-30allocgate: split free out from resizeLee Cannon
2021-11-30allocgate: utilize a *const vtable fieldLee Cannon
2021-11-30allocgate: renamed getAllocator function to allocatorLee Cannon
2021-11-30allocgate: dont use a dummy temporary for stateless allocatorsLee Cannon
2021-11-30allocgate: std Allocator interface refactorLee Cannon
2021-10-20stage2: fix inline assembly with expression outputAndrew Kelley
Thanks @g-w1 for the print_air.zig implementation for inline assembly. I copied it and slightly modified it from your open pull request.
2021-10-04migrate from `std.Target.current` to `@import("builtin").target`Andrew Kelley
closes #9388 closes #9321
2021-09-01std: reorganization that allows new usingnamespace semanticsAndrew Kelley
The proposal #9629 is now accepted, usingnamespace stays but no longer puts identifiers in scope.
2021-09-01std.os reorganization, avoiding `usingnamespace`Andrew Kelley
The main purpose of this branch is to explore avoiding the `usingnamespace` feature of the zig language, specifically with regards to `std.os` and related functionality. If this experiment is successful, it will provide a data point on whether or not it would be practical to entirely remove `usingnamespace` from the language. In this commit, `usingnamespace` has been completely eliminated from the Linux x86_64 compilation path, aside from io_uring. The behavior tests pass, however that's as far as this branch goes. It is very breaking, and a lot more work is needed before it could be considered mergeable. I wanted to put a pull requset up early so that zig programmers have time to provide feedback. This is progress towards closing #6600 since it clarifies where the actual "owner" of each declaration is, and reduces the number of different ways to import the same declarations. One of the main organizational strategies used here is to do namespacing with real namespaces (e.g. structs) rather than by having declarations share a common prefix (the C strategy). It's no coincidence that `usingnamespace` has similar semantics to `#include` and becomes much less necessary when using proper namespaces.
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-06-21fix code broken from previous commitJacob G-W
2021-06-09Add a logging allocator that uses std.log (#8511)Lee Cannon
2021-06-06std: Add helpers to safely align pointersLemonBoy
Add two helpers to ensure people won't ignore some edge cases such as pointers overflowing the address space. Also fix #8924 to some degree, the amount of unchecked alignForward is still scary.
2021-05-08Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * doc/langref.html.in * lib/std/enums.zig * lib/std/fmt.zig * lib/std/hash/auto_hash.zig * lib/std/math.zig * lib/std/mem.zig * lib/std/meta.zig * test/behavior/alignof.zig * test/behavior/bitcast.zig * test/behavior/bugs/1421.zig * test/behavior/cast.zig * test/behavior/ptrcast.zig * test/behavior/type_info.zig * test/behavior/vector.zig Master branch added `try` to a bunch of testing function calls, and some lines also had changed how to refer to the native architecture and other `@import("builtin")` stuff.
2021-05-08std: update usage of std.testingVeikka Tuominen
2021-04-28std: remove redundant comptime keywordAndrew Kelley
@g-w1's fancy new compile error in action
2021-04-15std: change `@import("builtin")` to `std.builtin`Andrew Kelley
2020-12-31Year++Frank Denis
2020-12-28std/heap: fix documentation of raw_c_allocatorIsaac Freund
This is not in fact safe to use with GeneralPurposeAllocator as GPA requires align(page_size) but raw_c_allocator provides only @alignOf(std.c.max_align_t).
2020-12-17Fix StackFallbackAllocatorLuuk de Gram
2020-11-18add std.heap.raw_c_allocatorAndrew Kelley
This API does what `std.heap.c_allocator` previously did. See the new doc comments for more details.
2020-11-18Merge pull request #6385 from LemonBoy/callocatorAndrew Kelley
std: Make C allocator respect the required alignment
2020-11-06change debug.assert to testing.expect in testsxackus
2020-11-05Fix typo, remove debug leftover, rename few fnsLemonBoy
2020-11-05Implement a fallback mechanism for posix_memalignLemonBoy
Do the alignment dance by ourselves whenever posix_memalign is not available. Don't try to use malloc as it has too many edge cases, figuring out whether a block of memory is manually aligned by the mechanism above or is directly coming from malloc becomes too hard to be valuable.
2020-11-05std: Make C allocator respect the required alignmentLemonBoy
Use posix_memalign where available and the _aligned_{malloc,free} API on Windows. Closes #3783
2020-10-17Make std.meta.Int accept a signedness parameterJan Prudil
2020-09-25std: ArenaAllocator tries to resize before allocatingLemonBoy
Closes #5116
2020-09-20std: Fix metadata corruption in HeapAllocatorLemonBoy
HeapAllocator stores the pointer returned by HeapAlloc right after the data block and, after the recent allocator refactoring, the space for this pointer was not taken into account in the calculation of the final block size. Fixes #5830
2020-09-06Merge pull request #6239 from pfgithub/patch-1Andrew Kelley
Support allocating 0 bit types
2020-09-03Test 0 bit allocationpfg
2020-09-03update uses of deprecated type field accessVexu
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-08-08std.heap.page_allocator: Windows support for growing without remappingAndrew Kelley
2020-08-08stage1: deal with WebAssembly not supporting @returnAddress()Andrew Kelley
This makes `@returnAddress()` return 0 for WebAssembly (when not using the Emscripten OS) and avoids trying to capture stack traces for the general purpose allocator on that target.
2020-08-08std.mem.Allocator: add return_address to the interfaceAndrew Kelley
The high level Allocator interface API functions will now do a `@returnAddress()` so that stack traces captured by allocator implementations have a return address that does not include the Allocator overhead functions. This makes `4` a more reasonable default for how many stack frames to capture.
2020-08-07improvements & fixes for general purpose allocator integrationAndrew Kelley
* std.Mutex API is improved to not have init() deinit(). This API is designed to support static initialization and does not require any resource cleanup. This also happens to work around some kind of stage1 behavior that wasn't letting the new allocator mutex code get compiled. * the general purpose allocator now returns a bool from deinit() which tells if there were any leaks. This value is used by the test runner to fail the tests if there are any. * self-hosted compiler is updated to use the general purpose allocator when not linking against libc.
2020-08-07std: introduce GeneralPurposeAllocatorAndrew Kelley
`std.GeneralPurposeAllocator` is now available. It is a function that takes a configuration struct (with default field values) and returns an allocator. There is a detailed description of this allocator in the doc comments at the top of the new file. The main feature of this allocator is that it is *safe*. It prevents double-free, use-after-free, and detects leaks. Some deprecation compile errors are removed. The Allocator interface gains `old_align` as a new parameter to `resizeFn`. This is useful to quickly look up allocations. `std.heap.page_allocator` is improved to use mmap address hints to avoid obtaining the same virtual address pages when unmapping and mapping pages. The new general purpose allocator uses the page allocator as its backing allocator by default. `std.testing.allocator` is replaced with usage of this new allocator, which does leak checking, and so the LeakCheckAllocator is retired. stage1 is improved so that the `@typeInfo` of a pointer has a lazy value for the alignment of the child type, to avoid false dependency loops when dealing with pointers to async function frames. The `std.mem.Allocator` interface is refactored to be in its own file. `std.Mutex` now exposes the dummy mutex with `std.Mutex.Dummy`. This allocator is great for debug mode, however it needs some work to have better performance in release modes. The next step will be setting up a series of tests in ziglang/gotta-go-fast and then making improvements to the implementation.
2020-07-12Make allocator test functions publicSam Tebbs
2020-07-11run zig fmt on std lib and self hostedVexu
2020-06-28Fix issue 5741, use after freeJonathan Marler
2020-06-28WasmPageAllocator: fix bug not aligning allocationsJonathan Marler
2020-06-27new allocator interface after Andrew Kelley reviewJonathan Marler