util/dictionary: some style fixes
This commit is contained in:
parent
ebdd8fb349
commit
0174c8f01b
@ -6,21 +6,22 @@ use ffi::*;
|
|||||||
pub struct Dictionary<'a> {
|
pub struct Dictionary<'a> {
|
||||||
pub ptr: *mut AVDictionary,
|
pub ptr: *mut AVDictionary,
|
||||||
|
|
||||||
own: bool,
|
_own: bool,
|
||||||
_marker: PhantomData<&'a i32>,
|
_marker: PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Dictionary<'a> {
|
impl<'a> Dictionary<'a> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Dictionary { ptr: ptr::null_mut(), own: true, _marker: PhantomData }
|
Dictionary { ptr: ptr::null_mut(), _own: true, _marker: PhantomData }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wrap(ptr: *mut AVDictionary) -> Self {
|
pub fn wrap(ptr: *mut AVDictionary) -> Self {
|
||||||
Dictionary { ptr: ptr, own: false, _marker: PhantomData }
|
Dictionary { ptr: ptr, _own: false, _marker: PhantomData }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take(&mut self) -> *mut AVDictionary {
|
pub fn take(&mut self) -> *mut AVDictionary {
|
||||||
self.own = false;
|
self._own = false;
|
||||||
|
|
||||||
self.ptr
|
self.ptr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -28,7 +29,7 @@ impl<'a> Dictionary<'a> {
|
|||||||
impl<'a> Drop for Dictionary<'a> {
|
impl<'a> Drop for Dictionary<'a> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
if self.own && self.ptr != ptr::null_mut() {
|
if self._own && self.ptr != ptr::null_mut() {
|
||||||
av_dict_free(&mut self.ptr);
|
av_dict_free(&mut self.ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user