mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
allocgate: fix failing tests
This commit is contained in:
parent
1093b09a98
commit
80bbf234e0
5 changed files with 10 additions and 10 deletions
|
|
@ -53,7 +53,7 @@ pub fn ScopedLoggingAllocator(
|
|||
len_align: u29,
|
||||
ra: usize,
|
||||
) error{OutOfMemory}![]u8 {
|
||||
const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra);
|
||||
const result = self.parent_allocator.allocFn(self.parent_allocator.ptr, len, ptr_align, len_align, ra);
|
||||
if (result) |_| {
|
||||
logHelper(
|
||||
success_log_level,
|
||||
|
|
@ -78,7 +78,7 @@ pub fn ScopedLoggingAllocator(
|
|||
len_align: u29,
|
||||
ra: usize,
|
||||
) error{OutOfMemory}!usize {
|
||||
if (self.parent_allocator.resizeFn(self.parent_allocator, buf, buf_align, new_len, len_align, ra)) |resized_len| {
|
||||
if (self.parent_allocator.resizeFn(self.parent_allocator.ptr, buf, buf_align, new_len, len_align, ra)) |resized_len| {
|
||||
if (new_len == 0) {
|
||||
logHelper(success_log_level, "free - success - len: {}", .{buf.len});
|
||||
} else if (new_len <= buf.len) {
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ pub fn ValidationAllocator(comptime T: type) type {
|
|||
|
||||
underlying_allocator: T,
|
||||
|
||||
pub fn init(allocator: T) @This() {
|
||||
pub fn init(underlying_allocator: T) @This() {
|
||||
return .{
|
||||
.underlying_allocator = allocator,
|
||||
.underlying_allocator = underlying_allocator,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ pub const FailingAllocator = struct {
|
|||
/// var a = try failing_alloc.create(i32);
|
||||
/// var b = try failing_alloc.create(i32);
|
||||
/// testing.expectError(error.OutOfMemory, failing_alloc.create(i32));
|
||||
pub fn init(allocator: mem.Allocator, fail_index: usize) FailingAllocator {
|
||||
pub fn init(internal_allocator: mem.Allocator, fail_index: usize) FailingAllocator {
|
||||
return FailingAllocator{
|
||||
.internal_allocator = allocator,
|
||||
.internal_allocator = internal_allocator,
|
||||
.fail_index = fail_index,
|
||||
.index = 0,
|
||||
.allocated_bytes = 0,
|
||||
|
|
|
|||
|
|
@ -6550,9 +6550,9 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||
ctx.objErrStage1("method call with first arg type wrong container",
|
||||
\\pub const List = struct {
|
||||
\\ len: usize,
|
||||
\\ allocator: Allocator,
|
||||
\\ allocator: *Allocator,
|
||||
\\
|
||||
\\ pub fn init(allocator: Allocator) List {
|
||||
\\ pub fn init(allocator: *Allocator) List {
|
||||
\\ return List {
|
||||
\\ .len = 0,
|
||||
\\ .allocator = allocator,
|
||||
|
|
@ -6573,7 +6573,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||
\\ x.init();
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:23:5: error: expected type 'Allocator', found '*List'",
|
||||
"tmp.zig:23:5: error: expected type '*Allocator', found '*List'",
|
||||
});
|
||||
|
||||
ctx.objErrStage1("binary not on number literal",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const Token = union(enum) {
|
|||
};
|
||||
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
const global_allocator = gpa.allocator();
|
||||
var global_allocator = gpa.allocator();
|
||||
|
||||
fn tokenize(input: []const u8) !ArrayList(Token) {
|
||||
const State = enum {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue