IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3851


Ignore:
Timestamp:
May 5, 2005, 11:25:47 AM (21 years ago)
Author:
desonia
Message:

fix for bug#348. When reading a string table element, the buffer needed
to be allocated before calling CFITSIO.

Location:
trunk/psLib/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataIO/psFits.c

    r3769 r3851  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-04-26 19:53:30 $
     9 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-05-05 21:25:47 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    11491149    }
    11501150
     1151    psTrace(".psFits.psFitsReadTableRow",5,"Table size is %ix%i\n",numCols, numRows);
    11511152    // the row parameter in the proper range?
    11521153    if (row < 0 || row >= numRows) {
     
    11721173                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status);
    11731174        }
    1174 
    11751175        // get the column type
    11761176        fits_get_coltype(fits->p_fd, col, &typecode, &repeat, &width, &status);
     
    11841184                fits_read_col(fits->p_fd, FITSTYPE, col,row+1, \
    11851185                              1, 1, NULL, &value, &anynul, &status); \
     1186                psTrace(".psFits.psFitsReadTableRow",5,"Column #%i, '%s', is type %i, repeat %i, Value = %g\n", \
     1187                        col, name, typecode, repeat, (double)value); \
    11861188                psMetadataAdd(data,PS_LIST_TAIL, name, \
    11871189                              PS_META_##TYPE, \
     
    11991201                READ_TABLE_ROW_CASE(TLOGICAL, bool, BOOL);
    12001202            case TSTRING: {
    1201                     char* value;
     1203                    char* value = psAlloc(repeat+1);
    12021204                    int anynul = 0;
    12031205                    fits_read_col(fits->p_fd, TSTRING, col,row+1,
    12041206                                  1, 1, NULL, &value, &anynul, &status);
     1207                    psTrace(".psFits.psFitsReadTableRow",5,"Column #%i, '%s', is type %i, repeat %i, value = %s\n",
     1208                            col, name, typecode, repeat, value);
    12051209                    if (anynul == 0) {
    12061210                        psMetadataAdd(data,PS_LIST_TAIL, name,
     
    12081212                                      "", value);
    12091213                    }
     1214                    psFree(value);
    12101215                    break;
    12111216                }
     
    14351440    }
    14361441
     1442
    14371443    psArray* table = psArrayAlloc(numRows);
    14381444
    14391445    for (int row = 0; row < numRows; row++) {
     1446        psTrace(".psFits.psFitsReadTable",5,"Reading row %i of %i\n",row, numRows);
    14401447        table->data[row] = psFitsReadTableRow(fits,row);
    14411448    }
  • trunk/psLib/src/fits/psFits.c

    r3769 r3851  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-04-26 19:53:30 $
     9 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-05-05 21:25:47 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    11491149    }
    11501150
     1151    psTrace(".psFits.psFitsReadTableRow",5,"Table size is %ix%i\n",numCols, numRows);
    11511152    // the row parameter in the proper range?
    11521153    if (row < 0 || row >= numRows) {
     
    11721173                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, &status);
    11731174        }
    1174 
    11751175        // get the column type
    11761176        fits_get_coltype(fits->p_fd, col, &typecode, &repeat, &width, &status);
     
    11841184                fits_read_col(fits->p_fd, FITSTYPE, col,row+1, \
    11851185                              1, 1, NULL, &value, &anynul, &status); \
     1186                psTrace(".psFits.psFitsReadTableRow",5,"Column #%i, '%s', is type %i, repeat %i, Value = %g\n", \
     1187                        col, name, typecode, repeat, (double)value); \
    11861188                psMetadataAdd(data,PS_LIST_TAIL, name, \
    11871189                              PS_META_##TYPE, \
     
    11991201                READ_TABLE_ROW_CASE(TLOGICAL, bool, BOOL);
    12001202            case TSTRING: {
    1201                     char* value;
     1203                    char* value = psAlloc(repeat+1);
    12021204                    int anynul = 0;
    12031205                    fits_read_col(fits->p_fd, TSTRING, col,row+1,
    12041206                                  1, 1, NULL, &value, &anynul, &status);
     1207                    psTrace(".psFits.psFitsReadTableRow",5,"Column #%i, '%s', is type %i, repeat %i, value = %s\n",
     1208                            col, name, typecode, repeat, value);
    12051209                    if (anynul == 0) {
    12061210                        psMetadataAdd(data,PS_LIST_TAIL, name,
     
    12081212                                      "", value);
    12091213                    }
     1214                    psFree(value);
    12101215                    break;
    12111216                }
     
    14351440    }
    14361441
     1442
    14371443    psArray* table = psArrayAlloc(numRows);
    14381444
    14391445    for (int row = 0; row < numRows; row++) {
     1446        psTrace(".psFits.psFitsReadTable",5,"Reading row %i of %i\n",row, numRows);
    14401447        table->data[row] = psFitsReadTableRow(fits,row);
    14411448    }
Note: See TracChangeset for help on using the changeset viewer.