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

+ 1
- 1
app/cmTimeLine.h View File

@@ -181,7 +181,7 @@ extern "C" {
181 181
     unsigned        seqId ); 
182 182
   
183 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 186
   // Return a count of sequences contained within this timeline.
187 187
   unsigned cmTimeLineSeqCount( cmTlH_t h );

Loading…
Cancel
Save