Changeset 15153
- Timestamp:
- Oct 1, 2007, 11:42:12 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pztool.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pztool.c
r15149 r15153 38 38 static bool copydoneCompleteExp(pxConfig *config); 39 39 static psArray *pzGetKnownCameras(pxConfig *config); 40 static psArray *pzArray AddArray(psArray *array, psArray *input);40 static psArray *pzArrayZip(psArray *arraySet); 41 41 42 42 # define MODECASE(caseName, func) \ … … 227 227 228 228 // array to hold the aggregate results 229 psArray * output= psArrayAlloc(0);229 psArray *cameraImfiles = psArrayAlloc(0); 230 230 231 231 for (long i = 0; i < psArrayLength(cameras); i++) { … … 233 233 if (!query) { 234 234 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 235 psFree( output);235 psFree(cameraImfiles); 236 236 return false; 237 237 } … … 273 273 psError(PS_ERR_UNKNOWN, false, "database error"); 274 274 psFree(query); 275 psFree( output);275 psFree(cameraImfiles); 276 276 return false; 277 277 } … … 281 281 if (!result) { 282 282 psError(PS_ERR_UNKNOWN, false, "database error"); 283 psFree( output);283 psFree(cameraImfiles); 284 284 return false; 285 285 } … … 287 287 psTrace("pztool", PS_LOG_INFO, "no rows found"); 288 288 psFree(result); 289 psFree( output);289 psFree(cameraImfiles); 290 290 return true; 291 291 } 292 292 293 // merge this query into theresult set294 p zArrayAddArray(output, result);293 // add this query into the array of result set 294 psArrayAdd(cameraImfiles, 0, result); 295 295 psFree(result); 296 296 } 297 298 // stitch the arrays of imfiles together 299 psArray *output = pzArrayZip(cameraImfiles); 300 psFree(cameraImfiles); 297 301 298 302 bool simple = false; … … 620 624 } 621 625 626 static psArray *pzArrayZip(psArray *arraySet) 627 { 628 long setSize = 0; 629 630 // figure out the size of the combined arrays 631 for (long i = 0; i < psArrayLength(arraySet); i++) { 632 setSize += psArrayLength(arraySet->data[i]); 633 } 634 635 psArray *output = psArrayAllocEmpty(setSize); 636 // loop over each array in the set forever 637 long index = 0; // the depth into each array 638 long counter; // counter - the total number of elements zipped so far 639 long i; // i - which array in the set 640 for (counter = 0, i = 0; 641 (counter < setSize) && (i < psArrayLength(arraySet)); 642 counter++, ++i, i = i % psArrayLength(arraySet)) { 643 644 psArray *array = arraySet->data[i]; 645 // make sure that this array has not run out of elements 646 if (index > (psArrayLength(arraySet) - 1)) { 647 continue; 648 } 649 650 psArrayAdd(output, 0, array->data[index]); 651 } 652 653 return output; 654 } 655 656 #if 0 622 657 static psArray *pzArrayAddArray(psArray *array, psArray *input) 623 658 { … … 628 663 return array; 629 664 } 665 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
