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 mem::uninitialized calls #276

Merged
merged 2 commits into from Jul 15, 2019

Conversation

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Jul 13, 2019

Part of gtk-rs/gir#806 (not a regen but same thing).

cc @EPashkin @sdroege

This one should be the last one.

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Jul 13, 2019

Thanks, 👍 after rust becomes 1.36.0

@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Jul 13, 2019

I forgot to update travis once again... Good catch @EPashkin !

src/pdf.rs Outdated
@@ -50,11 +50,11 @@ impl PdfSurface {

pub fn get_versions() -> impl Iterator<Item = PdfVersion> {
let vers_slice = unsafe {
let mut vers_ptr: *mut ffi::cairo_pdf_version_t = mem::uninitialized();
let mut vers_ptr = mem::MaybeUninit::<*mut ffi::cairo_pdf_version_t>::uninit();

This comment has been minimized.

Copy link
@EPashkin

EPashkin Jul 13, 2019

Member

<*mut ffi::cairo_pdf_version_t>:: seems unneeded here and in other places

This comment has been minimized.

Copy link
@GuillaumeGomez

GuillaumeGomez Jul 13, 2019

Author Member

True but explicit doesn't hurt I guess? :)

This comment has been minimized.

Copy link
@EPashkin

This comment has been minimized.

Copy link
@sdroege

sdroege Jul 14, 2019

Member

This one here is a pointer (to a pointer of versions), and we use ptr::null() or ptr::null_mut() for unitialized pointers elsewhere so it might be better to do that for consistency here too.

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Jul 13, 2019

@EPashkin

This comment has been minimized.

Copy link
Member

EPashkin commented Jul 13, 2019

@sdroege, record filled by cairo_pdf_get_versions, so IMHO current version is right.

src/pdf.rs Outdated
@@ -50,11 +50,11 @@ impl PdfSurface {

pub fn get_versions() -> impl Iterator<Item = PdfVersion> {
let vers_slice = unsafe {
let mut vers_ptr: *mut ffi::cairo_pdf_version_t = mem::uninitialized();
let mut vers_ptr = mem::MaybeUninit::<*mut ffi::cairo_pdf_version_t>::uninit();
let mut num_vers = 0;

This comment has been minimized.

Copy link
@sdroege

sdroege Jul 14, 2019

Member

This one can be MaybeUninit::uninit() for consistency with how we do things elsewhere.

src/ps.rs Outdated

std::slice::from_raw_parts(vers_ptr, num_vers as _)
std::slice::from_raw_parts(vers_ptr.assume_init(), num_vers as _)

This comment has been minimized.

Copy link
@sdroege

sdroege Jul 14, 2019

Member

Same as above

src/svg.rs Outdated

std::slice::from_raw_parts(vers_ptr, num_vers as _)
std::slice::from_raw_parts(vers_ptr.assume_init(), num_vers as _)

This comment has been minimized.

Copy link
@sdroege

sdroege Jul 14, 2019

Member

Same as above :)

@GuillaumeGomez GuillaumeGomez force-pushed the GuillaumeGomez:uninitialized branch from 48bf059 to f1b89e8 Jul 14, 2019
@GuillaumeGomez

This comment has been minimized.

Copy link
Member Author

GuillaumeGomez commented Jul 14, 2019

Updated.

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Jul 15, 2019

👍

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Jul 15, 2019

@GuillaumeGomez all green

@GuillaumeGomez GuillaumeGomez merged commit d66fce0 into gtk-rs:master Jul 15, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@GuillaumeGomez GuillaumeGomez deleted the GuillaumeGomez:uninitialized branch Jul 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.