Browse Source

cmTimeLine.h/c: cmTimeLineReadJson() now takes a handle ptr, rather than a handle,

so that it can correctly release the handle if the file read/parse fails.
master
kevin 11 years ago
parent
commit
8d00e8fe23
2 changed files with 6 additions and 6 deletions
  1. 5
    5
      app/cmTimeLine.c
  2. 1
    1
      app/cmTimeLine.h

+ 5
- 5
app/cmTimeLine.c View File

925
   if((rc = cmTimeLineInitialize(ctx,hp,cbFunc,cbArg)) != kOkTlRC )
925
   if((rc = cmTimeLineInitialize(ctx,hp,cbFunc,cbArg)) != kOkTlRC )
926
     return rc;
926
     return rc;
927
 
927
 
928
-  return  cmTimeLineReadJson(*hp,fn);
928
+  return cmTimeLineReadJson(hp,fn);
929
 }
929
 }
930
 
930
 
931
 const cmChar_t* cmTimeLineFileName( cmTlH_t h )
931
 const cmChar_t* cmTimeLineFileName( cmTlH_t h )
1317
   return rc;
1317
   return rc;
1318
 }
1318
 }
1319
     
1319
     
1320
-cmTlRC_t cmTimeLineReadJson(  cmTlH_t h, const cmChar_t* ifn )
1320
+cmTlRC_t cmTimeLineReadJson(  cmTlH_t* hp, const cmChar_t* ifn )
1321
 {
1321
 {
1322
   cmTlRC_t        rc  = kOkTlRC;
1322
   cmTlRC_t        rc  = kOkTlRC;
1323
   cmJsonH_t       jsH = cmJsonNullHandle;
1323
   cmJsonH_t       jsH = cmJsonNullHandle;
1325
   const cmChar_t* errLabelPtr;
1325
   const cmChar_t* errLabelPtr;
1326
   int i;
1326
   int i;
1327
 
1327
 
1328
-  _cmTl_t* p = _cmTlHandleToPtr(h);
1328
+  _cmTl_t* p = _cmTlHandleToPtr(*hp);
1329
  
1329
  
1330
   // open the json file
1330
   // open the json file
1331
   if( cmJsonInitializeFromFile(&jsH, ifn, &p->ctx ) != kOkJsRC )
1331
   if( cmJsonInitializeFromFile(&jsH, ifn, &p->ctx ) != kOkJsRC )
1381
 
1381
 
1382
  errLabel:
1382
  errLabel:
1383
   if( rc != kOkTlRC )
1383
   if( rc != kOkTlRC )
1384
-    _cmTimeLineFinalize(p);
1384
+    cmTimeLineFinalize(hp);
1385
 
1385
 
1386
   cmJsonFinalize(&jsH);
1386
   cmJsonFinalize(&jsH);
1387
   return rc;
1387
   return rc;
1604
   if((rc = cmTimeLineInitialize(ctx,&tlH,NULL,NULL)) != kOkTlRC )
1604
   if((rc = cmTimeLineInitialize(ctx,&tlH,NULL,NULL)) != kOkTlRC )
1605
     return rc;
1605
     return rc;
1606
 
1606
 
1607
-  if((rc = cmTimeLineReadJson(tlH,jsFn)) != kOkTlRC )
1607
+  if((rc = cmTimeLineReadJson(&tlH,jsFn)) != kOkTlRC )
1608
     goto errLabel;
1608
     goto errLabel;
1609
 
1609
 
1610
   if((rc = cmTimeLineInsert(tlH,"Mark",kMarkerTlId,"My Marker",10,0,NULL,0)) != kOkTlRC )
1610
   if((rc = cmTimeLineInsert(tlH,"Mark",kMarkerTlId,"My Marker",10,0,NULL,0)) != kOkTlRC )

+ 1
- 1
app/cmTimeLine.h View File

181
     unsigned        seqId ); 
181
     unsigned        seqId ); 
182
   
182
   
183
   // See src/data/tl0.json for an example JSON file.
183
   // See src/data/tl0.json for an example JSON file.
184
-  cmTlRC_t cmTimeLineReadJson(  cmTlH_t h, const cmChar_t* ifn );
184
+  cmTlRC_t cmTimeLineReadJson(  cmTlH_t* hp, const cmChar_t* ifn );
185
 
185
 
186
   // Return a count of sequences contained within this timeline.
186
   // Return a count of sequences contained within this timeline.
187
   unsigned cmTimeLineSeqCount( cmTlH_t h );
187
   unsigned cmTimeLineSeqCount( cmTlH_t h );

Loading…
Cancel
Save