IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 24, 2006, 12:55:05 PM (20 years ago)
Author:
Paul Price
Message:

Following today's meeting, we agreed that psVectorAlloc (and therefore
psArrayAlloc also) shall set the number of elements in use to equal the
number of elements allocated. We introduce new functions,
psVectorAllocEmpty and psArrayAllocEmpty, that allocate a vector and set
the length to zero.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/db/psDB.c

    r9690 r9730  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-10-21 01:09:37 $
     14 *  @version $Revision: 1.107 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-10-24 22:52:55 $
    1616 *
    1717 *  Copyright (C) 2005-2006  Joshua Hoblitt, University of Hawaii
     
    395395    // then reset n to 0 so elements are added from the beginning of
    396396    // the array
    397     column = psArrayAlloc(rowCount);
    398     column->n = 0;
     397    column = psArrayAllocEmpty(rowCount);
    399398
    400399    // Fetch each result
     
    459458
    460459    psVector *column = psVectorAlloc(stringColumn->n, type);
    461     //    column->n = column->nalloc;
    462460
    463461    // conversion functions are a portability issue
    464462    switch (type) {
    465463    case PS_TYPE_S8:
    466         column->n = column->nalloc;
    467464        PS_STR_ARRAY_TO_PTYPE(column->data.S8, stringColumn, atoi, psS8, PS_TYPE_S8);
    468465        break;
    469466    case PS_TYPE_S16:
    470         column->n = column->nalloc;
    471467        PS_STR_ARRAY_TO_PTYPE(column->data.S16, stringColumn, atoi, psS16, PS_TYPE_S16);
    472468        break;
    473469    case PS_TYPE_S32:
    474         column->n = column->nalloc;
    475470        PS_STR_ARRAY_TO_PTYPE(column->data.S32, stringColumn, atoi, psS32, PS_TYPE_S32);
    476471        break;
    477472    case PS_TYPE_S64:
    478         column->n = column->nalloc;
    479473        PS_STR_ARRAY_TO_PTYPE(column->data.S64, stringColumn, atoll, psS64, PS_TYPE_S64);
    480474        break;
    481475    case PS_TYPE_U8:
    482         column->n = column->nalloc;
    483476        PS_STR_ARRAY_TO_PTYPE(column->data.U8, stringColumn, atoi, psU8, PS_TYPE_U8);
    484477        break;
    485478    case PS_TYPE_U16:
    486         column->n = column->nalloc;
    487479        PS_STR_ARRAY_TO_PTYPE(column->data.U16, stringColumn, atoi, psU16, PS_TYPE_U16);
    488480        break;
    489481    case PS_TYPE_U32:
    490         column->n = column->nalloc;
    491482        PS_STR_ARRAY_TO_PTYPE(column->data.U32, stringColumn, atoi, psU32, PS_TYPE_U32);
    492483        break;
    493484    case PS_TYPE_U64:
    494         column->n = column->nalloc;
    495485        PS_STR_ARRAY_TO_PTYPE(column->data.U64, stringColumn, atoll, psU64, PS_TYPE_U64);
    496486        break;
    497487    case PS_TYPE_F32:
    498         column->n = column->nalloc;
    499488        PS_STR_ARRAY_TO_PTYPE(column->data.F32, stringColumn, atof, psF32, PS_TYPE_F32);
    500489        break;
    501490    case PS_TYPE_F64:
    502         column->n = column->nalloc;
    503491        PS_STR_ARRAY_TO_PTYPE(column->data.F64, stringColumn, atof, psF64, PS_TYPE_F64);
    504492        break;
    505493    case PS_TYPE_C32:
    506494        // this is a bogus SQL type
    507         column->n = column->nalloc;
    508495        PS_STR_ARRAY_TO_PTYPE(column->data.C32, stringColumn, atof, psC32, PS_TYPE_C32);
    509496        break;
     
    514501    case PS_TYPE_BOOL:
    515502        // valid for psVector?
    516         column->n = column->nalloc;
    517503        PS_STR_ARRAY_TO_PTYPE(column->data.U8, stringColumn, atoi, psU8, PS_TYPE_U8);
    518504        break;
     
    567553
    568554    // Create array to store single row
    569     psArray *rowSet = psArrayAlloc(1);
    570     rowSet->n = 0;
     555    psArray *rowSet = psArrayAllocEmpty(1);
    571556    psArrayAdd(rowSet, 0, (psPtr)row);
    572557
     
    697682    }
    698683
    699     psArray *rowData = psArrayAlloc(1);
     684    psArray *rowData = psArrayAllocEmpty(1);
    700685    psArrayAdd(rowData, 0, values);
    701686    long rowsAffected = p_psDBRunQueryPrepared(dbh, rowData, query);
     
    966951    // then reset n to 0 so elements are added from the beginning of
    967952    // the array
    968     resultSet = psArrayAlloc(rowCount);
     953    resultSet = psArrayAllocEmpty(rowCount);
    969954
    970955    field = mysql_fetch_fields(result);
     
    13041289    // Reset iterator to head of list
    13051290    psListIteratorSet(cursor, 0);
    1306     psArray *pKeys = psArrayAlloc(1);
     1291    psArray *pKeys = psArrayAllocEmpty(1);
    13071292    while ((item = psListGetAndIncrement(cursor))) {
    13081293        if (strstr(item->comment, "Primary Key")) {
Note: See TracChangeset for help on using the changeset viewer.