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> {
8686 ( * inner) . length = len;
8787 Buffer {
8888 inner : inner,
89- owned : false ,
89+ owned : true ,
9090 phantom : PhantomData ,
9191 }
9292 }
@@ -96,8 +96,7 @@ impl<T: TensorType> Buffer<T> {
9696 /// The caller is responsible for freeing the data.
9797 pub unsafe fn into_ptr ( mut self ) -> ( * mut T , usize ) {
9898 // TODO: remove
99- // This flag is used by drop.
100- self . owned = false ;
99+ ( * self . inner ) . data_deallocator = None ;
101100 ( self . data_mut ( ) , self . length ( ) )
102101 }
103102
@@ -128,7 +127,8 @@ impl<T: TensorType> Buffer<T> {
128127 /// Creates a buffer from data owned by the C API.
129128 ///
130129 /// `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.
132132 pub unsafe fn from_c ( buf : * mut tf:: TF_Buffer , owned : bool ) -> Self {
133133 Buffer {
134134 inner : buf,
You can’t perform that action at this time.
0 commit comments