File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ impl<T: TensorType> Buffer<T> {
86
86
( * inner) . length = len;
87
87
Buffer {
88
88
inner : inner,
89
- owned : false ,
89
+ owned : true ,
90
90
phantom : PhantomData ,
91
91
}
92
92
}
@@ -96,8 +96,7 @@ impl<T: TensorType> Buffer<T> {
96
96
/// The caller is responsible for freeing the data.
97
97
pub unsafe fn into_ptr ( mut self ) -> ( * mut T , usize ) {
98
98
// TODO: remove
99
- // This flag is used by drop.
100
- self . owned = false ;
99
+ ( * self . inner ) . data_deallocator = None ;
101
100
( self . data_mut ( ) , self . length ( ) )
102
101
}
103
102
@@ -128,7 +127,8 @@ impl<T: TensorType> Buffer<T> {
128
127
/// Creates a buffer from data owned by the C API.
129
128
///
130
129
/// `len` is the number of elements.
131
- /// The underlying data is freed when the buffer is destroyed if `owned` is true.
130
+ /// The underlying data is freed when the buffer is destroyed if `owned`
131
+ /// is true and the `buf` has a data deallocator.
132
132
pub unsafe fn from_c ( buf : * mut tf:: TF_Buffer , owned : bool ) -> Self {
133
133
Buffer {
134
134
inner : buf,
You can’t perform that action at this time.
0 commit comments