Changeset 13644
- Timestamp:
- 01/31/08 16:39:46 (4 months ago)
- Files:
-
- branches/1.5/gdal/port/cpl_vsi_mem.cpp (modified) (2 diffs)
- branches/1.5/gdal/port/cpl_vsil_win32.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.5/gdal/port/cpl_vsi_mem.cpp
r13333 r13644 533 533 534 534 std::map<CPLString,VSIMemFile*>::const_iterator iter; 535 char **papsz Result= NULL;535 char **papszDir = NULL; 536 536 int nPathLen = strlen(pszPath); 537 537 538 538 if( pszPath[nPathLen-1] == '/' ) 539 539 nPathLen--; 540 541 /* In case of really big number of files in the directory, CSLAddString */ 542 /* can be slow (see #2158). We then directly build the list. */ 543 int nItems=0; 544 int nAllocatedItems=0; 540 545 541 546 for( iter = oFileList.begin(); iter != oFileList.end(); iter++ ) … … 546 551 && strstr(pszFilePath+nPathLen+1,"/") == NULL ) 547 552 { 548 papszResult = CSLAddString( papszResult, 549 pszFilePath+nPathLen+1 ); 553 if (nItems == 0) 554 { 555 papszDir = (char**) CPLCalloc(2,sizeof(char*)); 556 nAllocatedItems = 1; 557 } 558 else if (nItems >= nAllocatedItems) 559 { 560 nAllocatedItems = nAllocatedItems * 2; 561 papszDir = (char**)CPLRealloc(papszDir, 562 (nAllocatedItems+2)*sizeof(char*)); 563 } 564 565 papszDir[nItems] = CPLStrdup(pszFilePath+nPathLen+1); 566 papszDir[nItems+1] = NULL; 567 568 nItems++; 550 569 } 551 570 } 552 571 553 return papsz Result;572 return papszDir; 554 573 } 555 574 branches/1.5/gdal/port/cpl_vsil_win32.cpp
r11304 r13644 461 461 if ( (hFile = _findfirst( pszFileSpec, &c_file )) != -1L ) 462 462 { 463 /* In case of really big number of files in the directory, CSLAddString */ 464 /* can be slow (see #2158). We then directly build the list. */ 465 int nItems=0; 466 int nAllocatedItems=0; 463 467 do 464 468 { 465 papszDir = CSLAddString(papszDir, c_file.name); 469 if (nItems == 0) 470 { 471 papszDir = (char**) CPLCalloc(2,sizeof(char*)); 472 nAllocatedItems = 1; 473 } 474 else if (nItems >= nAllocatedItems) 475 { 476 nAllocatedItems = nAllocatedItems * 2; 477 papszDir = (char**)CPLRealloc(papszDir, 478 (nAllocatedItems+2)*sizeof(char*)); 479 } 480 481 papszDir[nItems] = CPLStrdup(c_file.name); 482 papszDir[nItems+1] = NULL; 483 484 nItems++; 466 485 } while( _findnext( hFile, &c_file ) == 0 ); 467 486
