master
Andrew Kelley 2018-06-20 17:16:27 -04:00
parent 6bd8610063
commit e891f9cd9d
7 changed files with 11 additions and 13 deletions

View File

@ -116,7 +116,7 @@ fn startPuts(ctx: *Context) u8 {
const x = @bitCast(i32, r.random.scalar(u32));
const node = ctx.allocator.create(Queue(i32).Node{
.next = null,
.data = x
.data = x,
}) catch unreachable;
ctx.queue.put(node);
_ = @atomicRmw(isize, &ctx.put_sum, builtin.AtomicRmwOp.Add, x, AtomicOrder.SeqCst);

View File

@ -119,7 +119,7 @@ fn startPuts(ctx: *Context) u8 {
const x = @bitCast(i32, r.random.scalar(u32));
const node = ctx.allocator.create(Stack(i32).Node{
.next = null,
.data = x
.data = x,
}) catch unreachable;
ctx.stack.push(node);
_ = @atomicRmw(isize, &ctx.put_sum, builtin.AtomicRmwOp.Add, x, AtomicOrder.SeqCst);

View File

@ -279,9 +279,7 @@ pub fn openSelfDebugInfo(allocator: *mem.Allocator) !*ElfStackTrace {
var exe_file = try os.openSelfExe();
defer exe_file.close();
const st = try allocator.create(ElfStackTrace{
.symbol_table = try macho.loadSymbols(allocator, &io.FileInStream.init(&exe_file))
});
const st = try allocator.create(ElfStackTrace{ .symbol_table = try macho.loadSymbols(allocator, &io.FileInStream.init(&exe_file)) });
errdefer allocator.destroy(st);
return st;
},
@ -972,7 +970,7 @@ fn scanAllCompileUnits(st: *ElfStackTrace) !void {
try st.self_exe_file.seekTo(compile_unit_pos);
const compile_unit_die = try st.allocator().create( try parseDie(st, abbrev_table, is_64) );
const compile_unit_die = try st.allocator().create(try parseDie(st, abbrev_table, is_64));
if (compile_unit_die.tag_id != DW.TAG_compile_unit) return error.InvalidDebugInfo;

View File

@ -194,9 +194,9 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
pub fn allocateNode(list: *Self, allocator: *Allocator) !*Node {
comptime assert(!isIntrusive());
return allocator.create(Node{
.prev = null,
.next = null,
.data = undefined
.prev = null,
.next = null,
.data = undefined,
});
}

View File

@ -44,7 +44,7 @@ pub const Allocator = struct {
/// Alias of `create`
/// Call `destroy` with the result
pub fn construct(self: *Allocator, init: var) Error!*@typeOf(init) {
return self.create(init);
return self.create(init);
}
/// `ptr` should be the return value of `construct` or `create`

View File

@ -2583,8 +2583,8 @@ pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!*Thread
errdefer assert(windows.HeapFree(heap_handle, 0, bytes_ptr) != 0);
const bytes = @ptrCast([*]u8, bytes_ptr)[0..byte_count];
const outer_context = std.heap.FixedBufferAllocator.init(bytes).allocator.create(WinThread.OuterContext{
.thread = undefined,
.inner = context
.thread = undefined,
.inner = context,
}) catch unreachable;
outer_context.thread.data.heap_handle = heap_handle;

View File

@ -146,7 +146,7 @@ test "null with default unwrap" {
test "optional types" {
comptime {
const opt_type_struct = StructWithOptionalType { .t=u8, };
const opt_type_struct = StructWithOptionalType{ .t = u8 };
assert(opt_type_struct.t != null and opt_type_struct.t.? == u8);
}
}