Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace std.mem.copy with std.mem.copyForwards #19

Open
Rakhyvel opened this issue Dec 1, 2023 · 0 comments
Open

Replace std.mem.copy with std.mem.copyForwards #19

Rakhyvel opened this issue Dec 1, 2023 · 0 comments

Comments

@Rakhyvel
Copy link

Rakhyvel commented Dec 1, 2023

A recent PR for the Zig standard library removes the std.mem.copy function, which was an alias for std.mem.copyForwards. This function was used in toOwned().

A proposed fix:

pub fn toOwned(self: String) Error!?[]u8 {
    if (self.buffer != null) {
        const string = self.str();
        if (self.allocator.alloc(u8, string.len)) |newStr| {
            std.mem.copyForwards(u8, newStr, string); // replace std.mem.copy with std.mem.copyForwards
            return newStr;
        } else |_| {
            return Error.OutOfMemory;
        }
    }

    return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant