IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 16, 2011, 5:09:33 PM (15 years ago)
Author:
bills
Message:

In psFitsReadTableNew a fits table is empty return a psFitsTable struct with numRows and numCols set to zero.
This is compatible with psFitsReadTable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/psFitsTableNew.c

    r32361 r32409  
    117117
    118118psFitsTable* psFitsTableAlloc(int numCols, int numRows) {
    119     if (numCols <= 0) {
     119    if (numCols < 0) {
     120        // empty table
    120121        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    121122                "Can't allocate a psFitsTable with %d columns.", numCols);
     
    127128    table->numRows = numRows;
    128129    table->numCols = numCols;
    129     table->columns = psAlloc(sizeof(psFitsTableColumn) * numCols);
    130     memset(table->columns, sizeof(psFitsTableColumn) * numCols, 0);
     130    if (numCols > 0) {
     131        table->columns = psAlloc(sizeof(psFitsTableColumn) * numCols);
     132        memset(table->columns, sizeof(psFitsTableColumn) * numCols, 0);
     133    } else {
     134        table->columns = NULL;
     135    }
    131136    psMemSetDeallocator(table, (psFreeFunc) freeTable);
    132137
     
    141146    if (!readTableCheck(fits)) {
    142147        if (emptyTableCheck(fits)) {
    143             return NULL;
     148            psFitsTable *table = psFitsTableAlloc(0, 0);
     149            return table;
    144150        }
    145151        psError(PS_ERR_BAD_FITS, true, "Extension is not a table");
Note: See TracChangeset for help on using the changeset viewer.