Skip to content

regex_macros: Fix valgrind errors #13980

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/libregex_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,11 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
fn new(which: MatchKind) -> Threads {
Threads {
which: which,
// These unsafe blocks are used for performance reasons, as it
// gives us a zero-cost initialization of a sparse set. The
// trick is described in more detail here:
// http://research.swtch.com/sparse
// The idea here is to avoid initializing threads that never
// need to be initialized, particularly for larger regexs with
// a lot of instructions.
queue: unsafe { ::std::mem::uninit() },
sparse: unsafe { ::std::mem::uninit() },
queue: [Thread {
pc: 0,
captures: [None, ..$num_cap_locs];
}, ..$num_insts],
sparse: [0, ..$num_insts],
size: 0,
}
}
Expand Down