Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CNDTYPES.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ UCH -- "unsigned char"
SI -- "int16_t"
USI -- "uint16_t"
BOO -- "int16_t" // unambiguous 16-bit Boolean
TI -- "SI" // (rat) table index (subscript); 0 means unset.

// INT and variants: always 32 bits
INT -- "int32_t"
UINT -- "uint32_t"
TI -- "int32_t" // (rat) table index (subscript); 0 means unset.

// LI and variants: same size as pointer (4 on 32 bit / 8 on 64 bit)
#if CSE_ARCH == 64
Expand Down
16 changes: 11 additions & 5 deletions src/ancrec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,9 @@ void FC basAnc::regis() // "register" anchor for nextAnc() iteration. Constr
ancN = an; // set index in anchor
} // basAnc::regis
//---------------------------------------------------------------------------------------------------------------------------
void basAnc::desRecs( SI _mn, SI _n)
void basAnc::desRecs( // delete records
TI _mn /*=0*/, // 1st record to delete
TI _n /*=TI_MAX*/) // last record to delete
{
//if (mn <= n) // if any records allocated: protection for ptr vf call if nec??
if (ptr()) // if record memory is allocated
Expand Down Expand Up @@ -918,10 +920,10 @@ RC FC basAnc::reAl( TI _n, int erOp/*=ABT*/) // allocate space for n (0=default
return RCBAD; // check anchor
#endif
if (_n < 1)
_n = 1 + 1024/eSz; // if # records not specified, use 1k's worth plus 1
_n = max( 5, 1024/eSz); // if # records not specified, use 1k's worth (at least 5)
TI _nAl = _n+1; // space [0] not used (all 0's for grounding) --> max subscr+1 is n+1
size_t sz = _nAl * eSz; // size that must be allocated
desRecs(_nAl, 32767); // insurance: destroy any excess existing records if making block smaller
desRecs(_nAl); // insurance: destroy any excess existing records if making block smaller
record* ptrWas = ptr(); // NULL if this is initial allocation
RC rc = dmral( pptr(), sz, erOp|DMZERO); // (re)alloc memory, zero new space, dmpak.cpp
if (rc) // if failed
Expand Down Expand Up @@ -982,8 +984,12 @@ RC basAnc::add( // construct record i (0 = next). Allocs if nec.
if ( i >= nAl // if (more) record spaces must be allocated (nAl is +1; i,n are not)
|| !ptr() ) // insurance
{
UINT sz = (UINT)nAl*eSz + 1024; // new size in bytes to add 1 + 1K's worth of record spaces (nAl is +1)
TI _n = max( (USI)(sz/eSz), (USI)i); // add 1 + 1K's worth of spaces, or to req'd rec # if more.
#if 1 // add bigger chunks for big records, 9-3-2024
TI _n = max(i, nAl + max(5, 1024/eSz)); // new count: add 5 or 1K's worth (at least callers req'd rec #)
#else
0 UINT sz = (UINT)nAl*eSz + 1024; // new size in bytes to add 1 + 1K's worth of record spaces (nAl is +1)
0 TI _n = max( sz/eSz, UINT( i)); // add 1 + 1K's worth of spaces, or to req'd rec # if more.
#endif
if (reAl(_n, erOp))
return RCBAD; // (re)alloc rec spaces 1.._n, init nAl, ptr(), space[0], etc. above.
}
Expand Down
13 changes: 3 additions & 10 deletions src/ancrec.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ typedef basAnc* BP; // basAnc pointer -- formerly used to localize NEARness
skip these bytes in bitwise memset/memcpy operations.
Far forced 2-94 with compile option so same in 16/32 and in large/huge (srfd.cpp is huge) */

inline constexpr TI TI_MAX = INT_MAX; // maximum number of records in rat

/*---- Field (member) Status Byte Bits --------------------------------------

These are in unsigned char sstat[] array generated at end of each record
Expand Down Expand Up @@ -125,7 +127,7 @@ class basAnc // base class for record anchors: basAnc<recordName>
protected:
virtual void conRec( TI i, SI noZ=0) = 0; // execute constructor for record i
virtual void desRec( TI i) = 0; // .. destructor
void desRecs( TI mn=0, TI n=32767); // destroy all or range of records (as b4 freeing block)
void desRecs( TI mn=0, TI n=TI_MAX); // destroy all or range of records (as b4 freeing block)
}; // class basAnc

// for ARRAY field, the following are used in each element's status byte
Expand Down Expand Up @@ -373,7 +375,6 @@ template <class T> class anc : public basAnc


protected:
void desRecs( TI mn=0, TI n=32767); // ~ all records or range (as b4 freeing block)
virtual void desRec( TI i)
{ if (p[i].r_status)
p[i].T::~T(); // destroy record if constructed
Expand Down Expand Up @@ -457,14 +458,6 @@ x n = nAl = 0; // say no records in use, none allocated: insurance
}
} // anc<T>::~anc
//-------------------------------------------------------------------------------------------------------------------------
template <class T> void anc<T>::desRecs( SI _mn, SI _n)
// ?? why isn't basAnc::desRecs sufficient, 5-31-92?
{
if (ptr()) // if record memory is allocated
for (TI i = max(mn,_mn); i <= min(n,_n); i++) // loop allocated record spaces in range given by caller
desRec(i); // conditionally destroy record in space with record-deriv d'tor ~T.
} // anc<T>::desRecs
//-------------------------------------------------------------------------------------------------
template <class T> int anc<T>::GetCount(
int options) const // passed to T.IsCountable
{
Expand Down
2 changes: 1 addition & 1 deletion src/cncp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ BOO COOLPLANT::nxChStg( CHILLER *&ch, int _stgi /*=-1*/ ) // first/next chille
}

// access stage's chiller info
TI* stg = (SI *)((char *)cpStage1 + _stgi * sizeof(cpStage1)); // assumes stage arrays same and in order.
TI* stg = (TI *)((char *)cpStage1 + _stgi * sizeof(cpStage1)); // assumes stage arrays same and in order.

// access next chiller of stage. Code similar to AH::nxTsCzn, HEATPLANT::nxBlrStg
TI* chs; // temp for ptr into stg[]
Expand Down
2 changes: 1 addition & 1 deletion src/cncult4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ RC topCol( int isExport)
rp->wid += colp->colGap + colp->colWid;

// add this column to end of column list for its report
SI* pNxColi;
TI* pNxColi;
for (pNxColi = &rp->coli; *pNxColi; pNxColi = &colB->p[*pNxColi].nxColi ) // find end of list so far
;
*pNxColi = colp->ss; // set rp->coli (1st column) or prev column->nxColi
Expand Down
2 changes: 1 addition & 1 deletion src/cnhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ BOO HEATPLANT::nxBlrStg( BOILER *&blr, SI _stgi /*=-1*/ ) // first/next boiler
}

// access stage's boiler info
TI* stg = (SI *)((char *)hpStage1 + _stgi * sizeof(hpStage1)); // assumes stage arrays same and in order.
TI* stg = (TI *)((char *)hpStage1 + _stgi * sizeof(hpStage1)); // assumes stage arrays same and in order.

// access next boiler of stage. Code similar to AH::nxTsCzn.
TI* blrs; // temp for ptr into stg[]
Expand Down
3 changes: 2 additions & 1 deletion src/cul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2425,7 +2425,8 @@ LOCAL RC FC datPt() // point to DAT and KDAT data storage per xSp->c, e, fs0
case TYIREF:
case TYREF:
dtMustBe = DTTI;
break; // sz = 2 preset
sz = sizeof(TI);
break;
case TYDOY:
dtMustBe = DTDOY;
break;
Expand Down