Use `isNil` to check null pointers
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
This commit is contained in:
parent
af27abbaca
commit
b88f75efce
|
@ -26,7 +26,8 @@ proc instantiate(descriptor: ptr Lv2Descriptor; sampleRate: cdouble;
|
||||||
let amp: ptr MidiTransposePlugin = createShared(MidiTransposePlugin)
|
let amp: ptr MidiTransposePlugin = createShared(MidiTransposePlugin)
|
||||||
amp.map = cast[ptr UridMap](lv2FeaturesData(features, lv2UridMap))
|
amp.map = cast[ptr UridMap](lv2FeaturesData(features, lv2UridMap))
|
||||||
|
|
||||||
if amp.map == nil:
|
if amp.map.isNil:
|
||||||
|
freeShared(amp)
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
amp.midi_urid = amp.map.map(amp.map.handle, lv2MidiMidiEvent)
|
amp.midi_urid = amp.map.map(amp.map.handle, lv2MidiMidiEvent)
|
||||||
|
|
|
@ -31,7 +31,7 @@ proc atomTotalSize*(atom: ptr Atom): uint32 {.inline.} =
|
||||||
## Return true iff `atom` is null.
|
## Return true iff `atom` is null.
|
||||||
##
|
##
|
||||||
proc atomIsNull*(atom: ptr Atom): bool {.inline.} =
|
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`.
|
## Return true iff `a` is equal to `b`.
|
||||||
|
|
|
@ -7,11 +7,11 @@ import core
|
||||||
## present but have nil data.
|
## present but have nil data.
|
||||||
|
|
||||||
proc lv2FeaturesData*(features: ptr UncheckedArray[ptr Lv2Feature], uri: string): pointer =
|
proc lv2FeaturesData*(features: ptr UncheckedArray[ptr Lv2Feature], uri: string): pointer =
|
||||||
if features != nil:
|
if not features.isNil:
|
||||||
var i = 0
|
var i = 0
|
||||||
while true:
|
while true:
|
||||||
let feature = features[i]
|
let feature = features[i]
|
||||||
if feature == nil:
|
if feature.isNil:
|
||||||
break
|
break
|
||||||
|
|
||||||
if feature[].uri == uri.cstring:
|
if feature[].uri == uri.cstring:
|
||||||
|
|
Loading…
Reference in New Issue