Use `isNil` to check null pointers

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
This commit is contained in:
Christopher Arndt 2024-05-28 15:31:29 +02:00
parent af27abbaca
commit b88f75efce
3 changed files with 5 additions and 4 deletions

View File

@ -26,7 +26,8 @@ proc instantiate(descriptor: ptr Lv2Descriptor; sampleRate: cdouble;
let amp: ptr MidiTransposePlugin = createShared(MidiTransposePlugin)
amp.map = cast[ptr UridMap](lv2FeaturesData(features, lv2UridMap))
if amp.map == nil:
if amp.map.isNil:
freeShared(amp)
return nil
amp.midi_urid = amp.map.map(amp.map.handle, lv2MidiMidiEvent)

View File

@ -31,7 +31,7 @@ proc atomTotalSize*(atom: ptr Atom): uint32 {.inline.} =
## Return true iff `atom` is null.
##
proc atomIsNull*(atom: ptr Atom): bool {.inline.} =
return atom == nil or (atom.`type` == Urid(0) and atom.size == 0)
return atom.isNil or (atom.`type` == Urid(0) and atom.size == 0)
##
## Return true iff `a` is equal to `b`.

View File

@ -7,11 +7,11 @@ import core
## present but have nil data.
proc lv2FeaturesData*(features: ptr UncheckedArray[ptr Lv2Feature], uri: string): pointer =
if features != nil:
if not features.isNil:
var i = 0
while true:
let feature = features[i]
if feature == nil:
if feature.isNil:
break
if feature[].uri == uri.cstring: