Merge pull request #953 from der-teufel-programming/update_once_more

Update to latest master
This commit is contained in:
Mitchell Hashimoto
2023-11-30 14:17:46 -08:00
committed by GitHub
17 changed files with 39 additions and 39 deletions

View File

@@ -374,9 +374,9 @@ pub fn expandPath(alloc: Allocator, cmd: []const u8) !?[]u8 {
if (path_buf.len < path_len) return error.PathTooLong;
// Copy in the full path
mem.copy(u8, &path_buf, search_path);
@memcpy(path_buf[0..search_path.len], search_path);
path_buf[search_path.len] = std.fs.path.sep;
mem.copy(u8, path_buf[search_path.len + 1 ..], cmd);
@memcpy(path_buf[search_path.len + 1 ..][0..cmd.len], cmd);
path_buf[path_len] = 0;
const full_path = path_buf[0..path_len :0];
@@ -440,9 +440,9 @@ fn createNullDelimitedEnvMap(arena: mem.Allocator, env_map: *const EnvMap) ![:nu
var i: usize = 0;
while (it.next()) |pair| : (i += 1) {
const env_buf = try arena.allocSentinel(u8, pair.key_ptr.len + pair.value_ptr.len + 1, 0);
mem.copy(u8, env_buf, pair.key_ptr.*);
@memcpy(env_buf[0..pair.key_ptr.len], pair.key_ptr.*);
env_buf[pair.key_ptr.len] = '=';
mem.copy(u8, env_buf[pair.key_ptr.len + 1 ..], pair.value_ptr.*);
@memcpy(env_buf[pair.key_ptr.len + 1 ..], pair.value_ptr.*);
envp_buf[i] = env_buf.ptr;
}
std.debug.assert(i == envp_count);

View File

@@ -2501,7 +2501,7 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
.text => |data| {
// For text we always allocate just because its easier to
// handle all cases that way.
var buf = try self.alloc.alloc(u8, data.len);
const buf = try self.alloc.alloc(u8, data.len);
defer self.alloc.free(buf);
const text = configpkg.string.parse(buf, data) catch |err| {
log.warn(

View File

@@ -204,14 +204,14 @@ fn parseIntoField(
[]const u8 => value: {
const slice = value orelse return error.ValueRequired;
const buf = try alloc.alloc(u8, slice.len);
mem.copy(u8, buf, slice);
@memcpy(buf, slice);
break :value buf;
},
[:0]const u8 => value: {
const slice = value orelse return error.ValueRequired;
const buf = try alloc.allocSentinel(u8, slice.len, 0);
mem.copy(u8, buf, slice);
@memcpy(buf, slice);
buf[slice.len] = 0;
break :value buf;
},
@@ -709,7 +709,7 @@ pub fn LineIterator(comptime ReaderType: type) type {
// Trim any whitespace around it
const trim = std.mem.trim(u8, entry, whitespace);
if (trim.len != entry.len) {
std.mem.copy(u8, entry, trim);
std.mem.copyForwards(u8, entry, trim);
entry = entry[0..trim.len];
}
@@ -737,9 +737,9 @@ pub fn LineIterator(comptime ReaderType: type) type {
const len = key.len + value.len + 1;
if (entry.len != len) {
std.mem.copy(u8, entry, key);
std.mem.copyForwards(u8, entry, key);
entry[key.len] = '=';
std.mem.copy(u8, entry[key.len + 1 ..], value);
std.mem.copyForwards(u8, entry[key.len + 1 ..], value);
entry = entry[0..len];
}
}

View File

@@ -43,7 +43,7 @@ pub fn run(alloc: Allocator) !u8 {
const path = try std.fs.path.join(alloc, &.{ resources_dir, "themes" });
defer alloc.free(path);
var dir = try std.fs.cwd().openIterableDir(path, .{});
var dir = try std.fs.cwd().openDir(path, .{ .iterate = true });
defer dir.close();
var walker = try dir.walk(alloc);

View File

@@ -2246,7 +2246,7 @@ pub const Keybinds = struct {
const buf = try alloc.alloc(u8, value.len);
copy = buf;
std.mem.copy(u8, buf, value);
@memcpy(buf, value);
break :value buf;
};
errdefer if (copy) |v| alloc.free(v);

View File

@@ -2,23 +2,23 @@ const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
/// Same as std.mem.copy but prefers libc memmove if it is available
/// Same as std.mem.copyForwards but prefers libc memmove if it is available
/// because it is generally much faster.
pub inline fn move(comptime T: type, dest: []T, source: []const T) void {
if (builtin.link_libc) {
_ = memmove(dest.ptr, source.ptr, source.len * @sizeOf(T));
} else {
std.mem.copy(T, dest, source);
std.mem.copyForwards(T, dest, source);
}
}
/// Same as std.mem.copy but prefers libc memcpy if it is available
/// Same as std.mem.copyForwards but prefers libc memcpy if it is available
/// because it is generally much faster.
pub inline fn copy(comptime T: type, dest: []T, source: []const T) void {
if (builtin.link_libc) {
_ = memcpy(dest.ptr, source.ptr, source.len * @sizeOf(T));
} else {
std.mem.copy(T, dest, source);
@memcpy(dest[0..source.len], source);
}
}

View File

@@ -390,7 +390,7 @@ const PixmanImpl = struct {
var src_ptr = data.ptr;
var i: usize = 0;
while (i < height) : (i += 1) {
std.mem.copy(u8, dst_ptr, src_ptr[0 .. width * depth]);
@memcpy(dst_ptr[0 .. width * depth], src_ptr[0 .. width * depth]);
dst_ptr = dst_ptr[width * depth ..];
src_ptr += @as(usize, @intCast(stride));
}

View File

@@ -22,7 +22,7 @@ fn homeUnix(buf: []u8) !?[]u8 {
// First: if we have a HOME env var, then we use that.
if (std.os.getenv("HOME")) |result| {
if (buf.len < result.len) return Error.BufferTooSmall;
std.mem.copy(u8, buf, result);
@memcpy(buf[0..result.len], result);
return buf[0..result.len];
}
@@ -46,7 +46,7 @@ fn homeUnix(buf: []u8) !?[]u8 {
if (run.term == .Exited and run.term.Exited == 0) {
const result = trimSpace(run.stdout);
if (buf.len < result.len) return Error.BufferTooSmall;
std.mem.copy(u8, buf, result);
@memcpy(buf[0..result.len], result);
return buf[0..result.len];
}
}
@@ -56,7 +56,7 @@ fn homeUnix(buf: []u8) !?[]u8 {
const pw = try passwd.get(fba.allocator());
if (pw.home) |result| {
if (buf.len < result.len) return Error.BufferTooSmall;
std.mem.copy(u8, buf, result);
@memcpy(buf[0..result.len], result);
return buf[0..result.len];
}
@@ -71,7 +71,7 @@ fn homeUnix(buf: []u8) !?[]u8 {
if (run.term == .Exited and run.term.Exited == 0) {
const result = trimSpace(run.stdout);
if (buf.len < result.len) return Error.BufferTooSmall;
std.mem.copy(u8, buf, result);
@memcpy(buf[0..result.len], result);
return buf[0..result.len];
}

View File

@@ -123,14 +123,14 @@ pub fn get(alloc: Allocator) !Entry {
if (pw.pw_shell) |ptr| {
const source = std.mem.sliceTo(ptr, 0);
const sh = try alloc.alloc(u8, source.len);
std.mem.copy(u8, sh, source);
@memcpy(sh, source);
result.shell = sh;
}
if (pw.pw_dir) |ptr| {
const source = std.mem.sliceTo(ptr, 0);
const dir = try alloc.alloc(u8, source.len);
std.mem.copy(u8, dir, source);
@memcpy(dir, source);
result.home = dir;
}

View File

@@ -132,7 +132,7 @@ const WindowsPty = struct {
pub const Fd = windows.HANDLE;
// Process-wide counter for pipe names
var pipe_name_counter = std.atomic.Atomic(u32).init(1);
var pipe_name_counter = std.atomic.Value(u32).init(1);
out_pipe: windows.HANDLE,
in_pipe: windows.HANDLE,

View File

@@ -762,7 +762,7 @@ const Subprocess = struct {
// Copy it with a hyphen so its a login shell
const argv0_buf = try alloc.alloc(u8, argv0.len + 1);
argv0_buf[0] = '-';
std.mem.copy(u8, argv0_buf[1..], argv0);
@memcpy(argv0_buf[1..], argv0);
break :argv0 argv0_buf;
} else null;
@@ -2120,7 +2120,7 @@ const StreamHandler = struct {
return;
}
std.mem.copy(u8, &buf, title);
@memcpy(buf[0..title.len], title);
buf[title.len] = 0;
// Mark that we've seen a title

View File

@@ -130,7 +130,7 @@ pub fn MessageData(comptime Elem: type, comptime small_size: comptime_int) type
// If it fits in our small request, do that.
if (data.len <= Small.Max) {
var buf: Small.Array = undefined;
std.mem.copy(Elem, &buf, data);
@memcpy(buf[0..data.len], data);
return Self{
.small = .{
.data = buf,