From a89cadec847973c5ae96c084994f3cf306ee0362 Mon Sep 17 00:00:00 2001 From: Kevin Larke Date: Tue, 24 Feb 2015 15:40:49 -0800 Subject: [PATCH] app/cmTimeLine.h/c : cMTlXXXObjPtr() now returns NULL if the 'op' arg. is NULL. --- app/cmTimeLine.c | 10 +++++----- app/cmTimeLine.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/cmTimeLine.c b/app/cmTimeLine.c index 35e2008..3c4dbf2 100644 --- a/app/cmTimeLine.c +++ b/app/cmTimeLine.c @@ -131,7 +131,7 @@ unsigned _cmTlIdLabelToId( _cmTl_t* p, const cmChar_t* label ) // cast a generic object to a midi file object cmTlMidiFile_t* _cmTlMidiFileObjPtr( _cmTl_t* p, cmTlObj_t* op, bool errFl ) { - if( op->typeId != kMidiFileTlId ) + if( op==NULL || op->typeId != kMidiFileTlId ) { if( errFl && p != NULL) cmErrMsg(&p->err,kTypeCvtFailTlRC,"A time line object type promotion failed."); @@ -144,7 +144,7 @@ cmTlMidiFile_t* _cmTlMidiFileObjPtr( _cmTl_t* p, cmTlObj_t* op, bool errFl ) // cast a generic object to a midi event object cmTlMidiEvt_t* _cmTlMidiEvtObjPtr( _cmTl_t* p, cmTlObj_t* op, bool errFl ) { - if( op->typeId != kMidiEvtTlId ) + if( op==NULL || op->typeId != kMidiEvtTlId ) { if( errFl && p != NULL ) cmErrMsg(&p->err,kTypeCvtFailTlRC,"A time line object type promotion failed."); @@ -157,7 +157,7 @@ cmTlMidiEvt_t* _cmTlMidiEvtObjPtr( _cmTl_t* p, cmTlObj_t* op, bool errFl ) // case a generic object to an audio file object cmTlAudioFile_t* _cmTlAudioFileObjPtr( _cmTl_t* p, cmTlObj_t* op, bool errFl ) { - if( op->typeId != kAudioFileTlId ) + if( op==NULL || op->typeId != kAudioFileTlId ) { if( errFl && p != NULL) cmErrMsg(&p->err,kTypeCvtFailTlRC,"A time line object type promotion failed."); @@ -170,7 +170,7 @@ cmTlAudioFile_t* _cmTlAudioFileObjPtr( _cmTl_t* p, cmTlObj_t* op, bool errFl ) // cast a generic object an audio event object to cmTlAudioEvt_t* _cmTlAudioEvtObjPtr( _cmTl_t* p, cmTlObj_t* op, bool errFl ) { - if( op->typeId != kAudioEvtTlId ) + if( op==NULL || op->typeId != kAudioEvtTlId ) { if( errFl && p != NULL) cmErrMsg(&p->err,kTypeCvtFailTlRC,"A time line object type promotion failed."); @@ -183,7 +183,7 @@ cmTlAudioEvt_t* _cmTlAudioEvtObjPtr( _cmTl_t* p, cmTlObj_t* op, bool errFl ) // cast a generic object to a marker object cmTlMarker_t* _cmTlMarkerObjPtr( _cmTl_t* p, cmTlObj_t* op, bool errFl ) { - if( op->typeId != kMarkerTlId ) + if( op==NULL || op->typeId != kMarkerTlId ) { if( errFl && p != NULL) cmErrMsg(&p->err,kTypeCvtFailTlRC,"A time line object type promotion failed."); diff --git a/app/cmTimeLine.h b/app/cmTimeLine.h index 2884d3d..458e8ba 100644 --- a/app/cmTimeLine.h +++ b/app/cmTimeLine.h @@ -161,7 +161,7 @@ extern "C" { // Same as cmTimeLineXXXObjPtr() but does not generate an error when // 'op' does not point to the correct type. These function quietly - // return NULL if the requested type does not match. + // return NULL if the requested type does not match or 'op' == NULL. cmTlMidiFile_t* cmTlMidiFileObjPtr( cmTlH_t h, cmTlObj_t* op ); cmTlAudioFile_t* cmTlAudioFileObjPtr( cmTlH_t h, cmTlObj_t* op ); cmTlMidiEvt_t* cmTlMidiEvtObjPtr( cmTlH_t h, cmTlObj_t* op );