This commit is contained in:
Jeff Hill
2002-12-05 23:59:44 +00:00
parent ad61c92957
commit 467ff91c4f
3 changed files with 31 additions and 43 deletions
-8
View File
@@ -23,14 +23,6 @@
#define NULL 0
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef NELEMENTS
#define NELEMENTS(array) (sizeof(array)/sizeof((array)[0]))
#endif
+18 -16
View File
@@ -142,17 +142,15 @@ inline gddStatus gdd::reference(void) const
{
fprintf(stderr,"reference of gdd marked \"no-referencing\" ignored!!\n");
gddAutoPrint("gdd::reference()",gddErrorNotAllowed);
rc=gddErrorNotAllowed;
rc = gddErrorNotAllowed;
}
else if ( this->ref_cnt < 0xffffffff ) {
this->ref_cnt++; // X aCC 818
}
else {
if ( this->ref_cnt >= 0xffffffff ) {
fprintf(stderr,"gdd reference count overflow!!\n");
gddAutoPrint("gdd::reference()",gddErrorOverflow);
rc=gddErrorOverflow;
}
else {
this->ref_cnt++; // X aCC 818
}
fprintf(stderr,"gdd reference count overflow!!\n");
gddAutoPrint("gdd::reference()",gddErrorOverflow);
rc=gddErrorOverflow;
}
return rc;
}
@@ -161,23 +159,27 @@ inline gddStatus gdd::unreference(void) const
{
int rc=0;
if(ref_cnt==0u)
if ( ref_cnt > 1u ) {
ref_cnt--;
}
else if ( ref_cnt == 0u )
{
fprintf(stderr,"gdd reference count underflow!!\n");
gddAutoPrint("gdd::unreference()",gddErrorUnderflow);
rc=gddErrorUnderflow;
}
else if(--ref_cnt<=0u) // X aCC 818
{
if(isManaged())
{
else {
if ( isManaged() ) {
// managed dd always destroys the entire thing
ref_cnt=1;
if(destruct) destruct->destroy((void *)this);
destruct=NULL;
}
else if(!isFlat())
else if(!isFlat()) {
// hopefully catch ref/unref missmatches while
// gdd is on free list
ref_cnt = 0;
delete this;
}
}
return rc;
}
+13 -19
View File
@@ -21,24 +21,18 @@
//
// smartGDDPointer::set()
//
void smartConstGDDPointer::set (const gdd *pNewValue)
void smartConstGDDPointer::set ( const gdd * pNewValue )
{
int gddStatus;
//
// dont change the ref count (and
// potentially unref a gdd that we are
// still using if the pointer isnt changing
//
if ( this->pConstValue == pNewValue ) {
return;
}
if ( this->pConstValue != NULL ) {
gddStatus = this->pConstValue->unreference();
assert ( ! gddStatus );
}
this->pConstValue = pNewValue;
if ( this->pConstValue != NULL ) {
gddStatus = this->pConstValue->reference();
assert ( ! gddStatus );
}
if ( pNewValue != this->pConstValue ) {
int gddStatus;
if ( pNewValue != NULL ) {
gddStatus = pNewValue->reference();
assert ( ! gddStatus );
}
if ( this->pConstValue != NULL ) {
gddStatus = this->pConstValue->unreference();
assert ( ! gddStatus );
}
this->pConstValue = pNewValue;
}
}