/* Whack */ static rc_t KTableWhack ( KTable *self ) { rc_t rc = 0; KRefcountWhack ( & self -> refcount, "KTable" ); if ( self -> db != NULL ) { rc = KDatabaseSever ( self -> db ); if ( rc == 0 ) self -> db = NULL; } if ( rc == 0 ) rc = KDBManagerSever ( self -> mgr ); if ( rc == 0 ) { KDirectoryRelease ( self -> dir ); free ( self ); return 0; } KRefcountInit ( & self -> refcount, 1, "KTable", "whack", "ktbl" ); return rc; }
static rc_t CC _KartItemDispose ( struct XFSGapKartItem * self ) { if ( self != NULL ) { KRefcountWhack ( & ( self -> refcount ), _sXFSGapKartItem_classname ); self -> project_id = 0; self -> object_id = 0; if ( self -> accession != NULL ) { free ( ( char * ) self -> accession ) ; self -> accession = NULL; } if ( self -> name != NULL ) { free ( ( char * ) self -> name ) ; self -> name = NULL; } if ( self -> description != NULL ) { free ( ( char * ) self -> description ) ; self -> description = NULL; } free ( self ); } return 0; } /* _KartItemDispose () */
/* Destroy * destroy */ LIB_EXPORT rc_t CC KCipherManagerDestroy ( KCipherManager *self ) { rc_t rc = 0; if ( self == NULL ) rc = RC ( rcKrypto, rcMgr, rcDestroying, rcSelf, rcNull ); else { if (self == singleton . ptr) { KCipherManager * reread; reread = atomic_test_and_set_ptr (&singleton, NULL, self); /* ignore results: just going for guaranteed atomicity though might not need it */ ( void ) reread; } /* no return value */ KRefcountWhack (&self->refcount, kciphermanager_classname); rc = KLockRelease (self->lock); free (self); } return rc; }
/* ---------------------------------------------------------------------- * Destroy * base class destruction called during the derived class destruction * * self is the cipher object * * memory release is the repsonsibility of the derived class destructor */ rc_t KCipherDestroy (KCipher * self) { if (self) { KRefcountWhack (&self->refcount, self->name); } return 0; }
/* Whack */ static rc_t KDyldWhack ( KDyld *self ) { KRefcountWhack ( & self -> refcount, "KDyld" ); VectorWhack ( & self -> search, KDirRefRelease, NULL ); free ( self ); return 0; }
/* Whack */ static rc_t KSymAddrWhack ( KSymAddr *self ) { KRefcountWhack ( & self -> refcount, "KSymAddr" ); KDylibSever ( self -> lib ); free ( self ); return 0; }
static rc_t KNSManagerDestroy( struct KNSManager *self ) { if ( self == NULL ) return RC( rcNS, rcFile, rcDestroying, rcSelf, rcNull ); KRefcountWhack( &self->refcount, knsmanager_classname ); free( self ); kns_mgr_singleton = NULL; return 0; }
/* Whack */ static rc_t KDlsetWhack ( KDlset *self ) { KRefcountWhack ( & self -> refcount, "KDlset" ); VectorWhack ( & self -> name, NULL, NULL ); VectorWhack ( & self -> ord, KDylibVectRelease, NULL ); KDyldSever ( self -> dl ); free ( self ); return 0; }
/* Whack */ static rc_t KDatabaseWhack ( KDatabase *self ) { rc_t rc = 0; KDBManager *mgr = self -> mgr; KSymbol * symb; assert ( mgr != NULL ); KRefcountWhack ( & self -> refcount, "KDatabase" ); /* release dad */ if ( self -> dad != NULL ) { rc = KDatabaseSever ( self -> dad ); if ( rc != 0 ) return rc; self -> dad = NULL; } /* shut down md5 sum file if it is open */ KMD5SumFmtRelease ( self -> md5 ), self -> md5 = NULL; /* remove from mgr */ symb = KDBManagerOpenObjectFind (mgr, self->path); if (symb != NULL) { rc = KDBManagerOpenObjectDelete (mgr, symb); if (rc == 0) { /* release manager should never fail */ rc = KDBManagerSever ( mgr ); if ( rc != 0 ) rc = KDBManagerOpenObjectAdd (mgr, symb); else { /* complete */ KDirectoryRelease ( self -> dir ); free ( self ); return 0; } } } KRefcountInit ( & self -> refcount, 1, "KDatabase", "whack", "kdb" ); return rc; }
/* Whack */ static rc_t CC VLinkerWhack ( VLinker *self ) { KRefcountWhack ( & self -> refcount, "VLinker" ); VectorWhack ( & self -> fact, LFactoryWhack, NULL ); VectorWhack ( & self -> special, LSpecialWhack, NULL ); BSTreeWhack ( & self -> scope, KSymbolWhack, NULL ); KDyldRelease ( self -> dl ); VLinkerSever ( self -> dad ); free ( self ); return 0; }
/* Whack */ static rc_t KDatabaseWhack ( KDatabase *self ) { rc_t rc = 0; /* unused: const KDBManager *mgr; */ KRefcountWhack ( & self -> refcount, "KDatabase" ); /* shut down md5 fmt file */ if ( self -> md5 != NULL ) { rc = KMD5SumFmtRelease ( self -> md5 ); if ( rc == 0 ) self -> md5 = NULL; } if ( rc == 0 ) { /* release dad */ if ( self -> dad != NULL ) { rc = KDatabaseSever ( self -> dad ); if ( rc == 0 ) self -> dad = NULL; } /* remove from mgr */ if ( rc == 0 ) { /* rc = KDBManagerSever ( self -> mgr, & self -> sym ); */ rc = KDBManagerSever ( self -> mgr ); /* complete */ if ( rc == 0 ) { KDirectoryRelease ( self -> dir ); free ( self ); return 0; } } } KRefcountInit ( & self -> refcount, 1, "KDatabase", "whack", "kdb" ); return rc; }
/* Whack */ rc_t VTableWhack ( VTable *self ) { KRefcountWhack ( & self -> refcount, "VTable" ); BSTreeWhack ( & self -> read_col_cache, VColumnRefWhack, NULL ); BSTreeWhack ( & self -> write_col_cache, VColumnRefWhack, NULL ); KMDataNodeRelease ( self -> col_node ); KMetadataRelease ( self -> meta ); KTableRelease ( self -> ktbl ); VSchemaRelease ( self -> schema ); VLinkerRelease ( self -> linker ); VDatabaseSever ( self -> db ); VDBManagerSever ( self -> mgr ); free ( self ); return 0; }
/* Whack */ static rc_t KDylibWhack ( KDylib *self ) { KRefcountWhack ( & self -> refcount, "KDylib" ); /* try to close library */ if ( !FreeLibrary( self -> handle ) ) { /* report error */ /* const char *msg = dlerror (); */ rc_t rc = RC ( rcFS, rcDylib, rcClosing, rcNoObj, rcUnknown ); /* LOGERR ( klogInt, rc, msg ); ( void ) msg; */ return rc; } free ( self ); return 0; }
LIB_EXPORT rc_t CC XFSNodeDispose ( const struct XFSNode * self ) { rc_t RCt; struct XFSNode * Node; RCt = 0; Node = ( struct XFSNode * ) self; /* pLogMsg ( klogDebug, "XFSNodeDispose ( $(node) )", "node=%p", ( void * ) self ); */ if ( Node == NULL ) { return XFS_RC ( rcNull ); } KRefcountWhack ( & ( Node -> refcount ), _sXFSNode_classname ); if ( Node -> Name != NULL ) { /* pLogMsg ( klogDebug, " [XFSNodeDispose] [$(node)] [$(name)]", "node=%p,name=%s", ( void * ) Node, Node -> Name ); */ free ( Node -> Name ); Node -> Name = NULL; } switch ( self -> vt -> v1.maj ) { case 1 : if ( Node -> vt -> v1.dispose != NULL ) { RCt = Node -> vt -> v1.dispose ( Node ); } break; default : RCt = XFS_RC ( rcBadVersion ); break; } return RCt; } /* XFSNodeDispose () */
LIB_EXPORT rc_t CC XFSTreeDispose ( struct XFSTree * self ) { rc_t RCt; RCt = 0; /* pLogMsg ( klogDebug, " |<- TreeDispose ( $(tree) )", "tree=%p", ( void * ) self ); */ if ( self == NULL ) { return XFS_RC ( rcNull ); } if ( self -> Root != NULL ) { XFSNodeRelease ( self -> Root ); self -> Root = NULL; } if ( self -> Resource != NULL ) { free ( ( char * ) self -> Resource ); self -> Resource = NULL; } if ( self -> Version != NULL ) { free ( ( char * ) self -> Version ); self -> Version = NULL; } KRefcountWhack ( & ( self -> refcount ), _sXFSTree_classname ); free ( self ); return RCt; } /* XFSTreeDispose () */
LIB_EXPORT rc_t CC XFSTreeDispose ( struct XFSTree * self ) { rc_t RCt; RCt = 0; /* printf ( " |<- ThreeDispose ( 0x%p )\n", ( void * ) self ); */ if ( self == NULL ) { return XFS_RC ( rcNull ); } if ( self -> Root != NULL ) { XFSNodeRelease ( self -> Root ); self -> Root = NULL; } if ( self -> Resource != NULL ) { free ( ( char * ) self -> Resource ); self -> Resource = NULL; } if ( self -> Version != NULL ) { free ( ( char * ) self -> Version ); self -> Version = NULL; } KRefcountWhack ( & ( self -> refcount ), _sXFSTree_classname ); free ( self ); return RCt; } /* XFSTreeDispose () */
/* Whack */ static rc_t KColumnWhack ( KColumn *self ) { rc_t rc; KRefcountWhack ( & self -> refcount, "KColumn" ); /* shut down index */ rc = KColumnIdxWhack ( & self -> idx ); if ( rc == 0 ) { /* shut down data fork */ KColumnDataWhack ( & self -> df ); /* release owning table should never fail, and our recovery is flawed */ if ( self -> tbl != NULL ) { rc = KTableSever ( self -> tbl ); if ( rc == 0 ) self -> tbl = NULL; } /* release manager should never fail */ if ( rc == 0 ) rc = KDBManagerSever ( self -> mgr ); if ( rc == 0 ) { KDirectoryRelease ( self -> dir ); free ( self ); return 0; } } KRefcountInit ( & self -> refcount, 1, "KColumn", "whack", "kcol" ); return rc; }
/* Whack */ static rc_t KDylibWhack ( KDylib *self ) { KRefcountWhack ( & self -> refcount, "KDylib" ); /* Darwin, especially before 10.5 doesn't/didn't do this well */ #if ! MAC /* try to close library */ if ( dlclose ( self -> handle ) ) { /* report error */ const char *msg = dlerror (); rc_t rc = RC ( rcFS, rcDylib, rcClosing, rcNoObj, rcUnknown ); LOGERR ( klogInt, rc, msg ); ( void ) msg; return rc; } #endif free ( self ); return 0; }