diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a6a7ba..581ea51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). ## [Unreleased] +### Added +- An `address?` predicate + ### Fixed - `nil` was not considered a null pointer - Primitive-serializing types fail to compile as arguments to downcall handles diff --git a/src/clj/coffi/mem.clj b/src/clj/coffi/mem.clj index fb050c3..a237442 100644 --- a/src/clj/coffi/mem.clj +++ b/src/clj/coffi/mem.clj @@ -130,6 +130,13 @@ [addr] (or (.equals (MemoryAddress/NULL) addr) (not addr))) +(defn address? + "Checks if an object is a memory address. + + `nil` is considered an address." + [addr] + (or (nil? addr) (instance? MemoryAddress addr))) + (defn slice-global "Gets a slice of the global address space.