IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 18, 2006, 12:20:45 PM (20 years ago)
Author:
Paul Price
Message:

Updating to use psLib rel11. Main problem was that vector and array lengths ('n' element) are no longer set to equal the number of allocated values ('nalloc' element) when allocated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/stac/src/stacRead.c

    r6771 r6887  
    1313    int nFiles = filenames->n;          // The number of input files
    1414    psArray *images = psArrayAlloc(nFiles); // The input files, to be returned
     15    images->n = nFiles;
    1516    assert(!headers || ! *headers || (*headers)->n == nFiles);
    1617    if (headers && ! *headers) {
    1718        *headers = psArrayAlloc(nFiles);
     19        (*headers)->n = nFiles;
    1820    }
    1921
     
    7173    psArray *coords = psArrayAlloc(BUFFER); // The array of coordinates to be returned
    7274    float x, y;                         // Coordinates to read
    73     int num = 0;                        // Number of coordinates read
    7475    while (fscanf(file, "%f %f\n", &x, &y) == 2) {
    7576        psPlane *coord = psPlaneAlloc();// A coordinate
    7677        coord->x = x;
    7778        coord->y = y;
    78         coords->data[num] = coord;
    79         num++;
    80         if (num % BUFFER) {
    81             coords = psArrayRealloc(coords, num + BUFFER);
    82         }
    83     }
    84     coords->n = num;
     79        coords->data[coords->n] = coord;
     80        coords->n++;
     81        if (coords->n % BUFFER == 0) {
     82            coords = psArrayRealloc(coords, coords->n + BUFFER);
     83        }
     84    }
    8585
    8686    psTrace("stac.read.coords", 5, "%d coordinates read.\n", num);
     
    184184    int nFiles = filenames->n;          // The number of input files
    185185    psArray *maps = psArrayAlloc(nFiles); // The maps, to be returned
     186    maps->n = nFiles;
    186187    char mapfile[MAXCHAR];              // Filename of map
    187188
Note: See TracChangeset for help on using the changeset viewer.