lib/xgboost/dmatrix.rb in xgb-0.7.2 vs lib/xgboost/dmatrix.rb in xgb-0.7.3
- old
+ new
@@ -50,21 +50,21 @@
handle_missing(flat_data, missing)
c_data.write_array_of_float(flat_data)
end
check_result FFI.XGDMatrixCreateFromMat(c_data, nrow, ncol, missing, @handle)
- ObjectSpace.define_finalizer(self, self.class.finalize(handle_pointer))
+ ObjectSpace.define_finalizer(@handle, self.class.finalize(handle_pointer.to_i))
@feature_names ||= ncol.times.map { |i| "f#{i}" }
end
self.label = label if label
self.weight = weight if weight
end
- def self.finalize(pointer)
+ def self.finalize(addr)
# must use proc instead of stabby lambda
- proc { FFI.XGDMatrixFree(pointer) }
+ proc { FFI.XGDMatrixFree(::FFI::Pointer.new(:pointer, addr)) }
end
def label
float_info("label")
end