Skip to content

Commit 8906d01

Browse files
committed
Fix cuda-free! by setting position to 0 beforehand.
1 parent d264802 commit 8906d01

File tree

1 file changed

+3
-2
lines changed
  • src/clojure/uncomplicate/clojurecuda

1 file changed

+3
-2
lines changed

src/clojure/uncomplicate/clojurecuda/core.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
[utils :refer [mask count-groups dragan-says-ex]]]
1919
[uncomplicate.clojure-cpp
2020
:refer [null? pointer byte-pointer string-pointer int-pointer long-pointer size-t-pointer
21-
pointer-pointer get-entry put-entry! safe type-pointer
21+
pointer-pointer get-entry put-entry! safe type-pointer position!
2222
capacity! address]]
2323
[uncomplicate.clojurecuda.info :as cuda-info]
2424
[uncomplicate.clojurecuda.internal
@@ -309,7 +309,8 @@
309309
(throw (ex-info (format "Unknown data type: %s." (str type)))))))
310310

311311
(defn cuda-free! [^Pointer dptr]
312-
(with-check (cudart/cudaFree (extract dptr)) (.setNull dptr))
312+
(when-not (null? dptr)
313+
(with-check (cudart/cudaFree (position! dptr 0)) (.setNull dptr)))
313314
dptr)
314315

315316
;; =================== Pinned Memory ================================================

0 commit comments

Comments
 (0)