static void ng_remove_invalid_nodes( p_ng generator, const uint32_t invalid_nodes ) { Vector temp_nodes; /* create a temp. vector */ VectorInit( &temp_nodes, 0, 5 ); /* copy all valid nodes into the temp. vector */ VectorForEach ( &(generator->nodes), false, ng_copy_valid_nodes, &temp_nodes ); /* clear all nodes so far... */ VectorWhack( &(generator->nodes), ng_node_destroy, NULL ); /* re-init the vector */ VectorInit( &(generator->nodes ), 0, 5 ); /* copy (swallow) the valid nodes back into the generator */ VectorCopy ( &temp_nodes, &(generator->nodes) ); /* correct the node count */ generator->node_count -= invalid_nodes; /* destroy the temp-vector, DO NOT PASS vdn_node_destroy into it */ VectorWhack ( &temp_nodes, NULL, NULL ); }
/* helper function for range-check */ static void num_gen_remove_invalid_nodes( num_gen* self ) { Vector temp_nodes; uint32_t count = VectorLength( &(self->nodes) ); if ( count < 1 ) return; /* create a temp. vector */ VectorInit( &temp_nodes, 0, count ); /* copy all valid nodes into the temp. vector */ VectorForEach ( &(self->nodes), false, num_gen_copy_valid_nodes, &temp_nodes ); /* clear all nodes so far..., DO NOT PASS num_gen_node_destroy into it */ VectorWhack( &(self->nodes), NULL, NULL ); /* initialize and copy (shallow) the valid nodes back into the generator */ VectorCopy ( &temp_nodes, &(self->nodes) ); /* destroy the temp-vector, DO NOT PASS num_gen_node_destroy into it */ VectorWhack ( &temp_nodes, NULL, NULL ); }
/* destroys a matcher-column */ static void CC matcher_destroy_col( void* node, void* data ) { p_mcol col = (p_mcol)node; if ( col == NULL ) return; if ( col->name != NULL ) free( col->name ); VectorWhack( &(col->src_types), matcher_destroy_type, NULL ); VectorWhack( &(col->dst_types), matcher_destroy_type, NULL ); VectorWhack( &(col->pairs), matcher_destroy_pair, NULL ); free( col ); }
/* 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 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; }
bool ng_set_range( p_ng generator, const int64_t first, const uint64_t count ) { bool res = ( generator != NULL ); if ( res ) { uint64_t num_1 = first; uint64_t num_2; /* this is necessary because virtual columns which have a infinite row-range, get reported with first=1,count=0 */ if ( count > 0 ) { num_2 = first + count - 1; } else { num_2 = first; } /* clear all nodes so far... */ VectorWhack( &(generator->nodes), ng_node_destroy, NULL ); /* re-init the vector */ VectorInit( &(generator->nodes ), 0, 5 ); generator->node_count = 0; generator->curr_node = 0; generator->curr_node_sub_pos = 0; res = ng_add_node( generator, num_1, num_2 ); } return res; }
static rc_t CC VNameListDestroy ( VNamelist *self ) { VectorWhack ( &(self->name_vector), VNameListDestroyNode, NULL ); free ( self ); return 0; }
static void CC release_skiplist_entry( BSTNode * n, void * data ) { struct skiplist_ref_node * node = ( struct skiplist_ref_node * )n; if ( node->name != NULL ) free( ( void * ) node->name ); VectorWhack ( &node->skip_ranges, release_skip, NULL ); /* wrapper callback reused from above */ free( ( void * ) node ); }
/* destroys the matcher */ rc_t matcher_destroy( matcher* self ) { if ( self == NULL ) return RC( rcVDB, rcNoTarg, rcDestroying, rcSelf, rcNull ); VectorWhack( &(self->mcols), matcher_destroy_col, NULL ); free( self ); return 0; }
/* * destroys the column-definitions-list */ rc_t col_defs_destroy( col_defs* defs ) { if ( defs == NULL ) return RC( rcVDB, rcNoTarg, rcDestroying, rcSelf, rcNull ); VectorWhack( &(defs->cols), col_defs_destroy_node, NULL ); free( defs ); return 0; }
/* Whack * destroy your vector */ LIB_EXPORT rc_t CC KRepositoryVectorWhack ( KRepositoryVector *self ) { if ( self == NULL ) return RC ( rcKFG, rcVector, rcDestroying, rcSelf, rcNull ); VectorWhack ( self, KRepositoryWhackEntry, NULL ); return 0; }
/* * destroys the redact-val-list */ rc_t redact_vals_destroy( redact_vals* vals ) { if ( vals == NULL ) return RC( rcVDB, rcNoTarg, rcDestroying, rcSelf, rcNull ); VectorWhack( &(vals->vals), redact_val_destroy_node, NULL ); free( vals ); return 0; }
void destroy_temp_registry( temp_registry * self ) { if ( self != NULL ) { VectorWhack ( &self -> lists, destroy_list, NULL ); KLockRelease ( self -> lock ); free( ( void * ) self ); } }
rc_t num_gen_destroy( num_gen* self ) { if ( self == NULL ) return RC( rcVDB, rcNoTarg, rcDestroying, rcSelf, rcNull ); VectorWhack( &(self->nodes), num_gen_node_destroy, NULL ); free( self ); return 0; }
void rgn_free( regions *rgn ) { free_array_file( &rgn->hdf5_regions ); VectorWhack ( &rgn->read_Regions, region_whack, NULL ); VectorWhack ( &rgn->sort_Regions, region_whack, NULL ); VectorWhack ( &rgn->stock_Regions, region_whack, NULL ); if ( rgn->data_32 != NULL ) free( rgn->data_32 ); if ( rgn->data_8 != NULL ) free( rgn->data_8 ); if ( rgn->complete_table != NULL ) free( rgn->complete_table ); if ( rgn->table_index != NULL ) free( rgn->table_index ); }
rc_t ng_destroy( p_ng generator ) { if ( generator == NULL ) { return RC( rcVDB, rcNoTarg, rcDestroying, rcParam, rcNull ); } VectorWhack( &(generator->nodes), ng_node_destroy, NULL ); free( generator ); return 0; }
rc_t vdn_destroy( num_gen* generator ) { if ( generator == NULL ) { return RC( rcVDB, rcNoTarg, rcDestroying, rcParam, rcNull ); } VectorWhack( &(generator->nodes), vdn_node_destroy, NULL ); free( generator ); return 0; }
/* Whack */ static rc_t KDyldWhack ( KDyld *self ) { KRefcountWhack ( & self -> refcount, "KDyld" ); VectorWhack ( & self -> search, KDirRefRelease, NULL ); free ( self ); return 0; }
rc_t num_gen_iterator_destroy( const num_gen_iter *self ) { num_gen_iter *temp; if ( self == NULL ) return RC( rcVDB, rcNoTarg, rcDestroying, rcSelf, rcNull ); temp = (num_gen_iter *)self; VectorWhack( &(temp->nodes), num_gen_node_destroy, NULL ); free( temp ); return 0; }
void SRATableDestroy ( SRATable *self ) { VectorWhack ( & self -> wcol, column_release, NULL ); VCursorRelease(self->curs); KMetadataRelease ( self -> meta ); VTableRelease ( self -> vtbl ); SRAMgrSever ( self -> mgr ); memset(self, 0, sizeof *self); free ( self ); }
void release_options( samdump_opts * opts ) { free_ref_regions( &opts->regions ); if ( opts->qname_prefix != NULL ) free( (void*)opts->qname_prefix ); if ( opts->qual_quant != NULL ) free( (void*)opts->qual_quant ); if( opts->outputfile != NULL ) free( (void*)opts->outputfile ); VNamelistRelease( opts->hdr_comments ); VNamelistRelease( opts->input_files ); VectorWhack ( &opts->mp_dist, release_range_wrapper, NULL ); }
rc_t num_gen_clear( num_gen* self ) { if ( self == NULL ) return RC( rcVDB, rcNoTarg, rcClearing, rcSelf, rcNull ); if ( VectorLength( &(self->nodes) ) > 0 ) { /* clear all nodes so far... */ VectorWhack( &(self->nodes), num_gen_node_destroy, NULL ); /* re-init the vector */ VectorInit( &(self->nodes ), 0, 5 ); } return 0; }
static rc_t get_column_specs ( const vtblcp_parms *pb, Vector *v, const VTable *stbl, VTable *dtbl ) { rc_t rc; /* always prepare the vector */ VectorInit ( v, 0, pb -> column_cnt ); /* unable at this moment to auto-determine column list */ if ( pb -> column_cnt == 0 ) { rc = RC ( rcExe, rcSchema, rcEvaluating, rcFunction, rcUnsupported ); LOGERR ( klogInt, rc, "failed to determine column specs" ); } else { uint32_t i; /* process command line arguments */ for ( rc = 0, i = 0; i < pb -> column_cnt; ++ i ) { const char *src = pb -> columns [ i ]; char *dst = malloc ( strlen ( src ) + 2 ); if ( dst == NULL ) { rc = RC ( rcExe, rcString, rcAllocating, rcMemory, rcExhausted ); break; } strcpy ( dst, src ); rc = VectorAppend ( v, NULL, dst ); if ( rc != 0 ) { free ( dst ); break; } } /* failure */ if ( rc != 0 ) VectorWhack ( v, free_column_spec, NULL ); } return rc; }
rc_t report_clear( p_report self ) { rc_t rc = 0; if ( self != NULL ) { VectorWhack ( &(self->data), report_data_whack, NULL ); VNamelistRelease ( self->columns ); /* ignores NULL */ if ( self->max_width != NULL ) { free( self->max_width ); self->max_width = NULL; } } else rc = RC( rcExe, rcNoTarg, rcConstructing, rcSelf, rcNull ); return rc; }
/* run */ static rc_t run ( const vtblcp_parms *pb ) { VDBManager *mgr; rc_t rc = init_mgr ( pb, & mgr ); if ( rc == 0 ) { VSchema *schema; rc = init_schema ( pb, mgr, & schema ); if ( rc == 0 ) { const VTable *stbl; rc = open_src_table ( pb, mgr, schema, & stbl ); if ( rc == 0 ) { VTable *dtbl; rc = open_dst_table ( pb, mgr, schema, & dtbl ); if ( rc == 0 ) { /* determine columns */ Vector v; rc = get_column_specs ( pb, & v, stbl, dtbl ); /* perform the copy */ if ( rc == 0 ) { rc = vtblcp ( pb, stbl, dtbl, & v ); VectorWhack ( & v, free_column_spec, NULL ); } /* cleanup */ rc = close_dst_table ( pb, dtbl, rc ); } VTableRelease ( stbl ); } VSchemaRelease ( schema ); } VDBManagerRelease ( mgr ); } return rc; }
/* ---------------------------------------------------------------------- * pull paramstring 1-N and comnvert then to internal VPaths */ static rc_t build_vpath_then_run () { rc_data data; data.rc = 0; VectorInit (&options.pathvpath, 0, VectorLength (&options.pathstr)); VectorForEach (&options.pathstr, false, build_vpath_one, &data); if (data.rc == 0) build_tree_then_run(); VectorWhack (&options.pathvpath, build_vpath_whack, NULL); return data.rc; }
/* * walks through the columns and checks every column against * a list of types, if one of the src-types of the column * is in the list it is marked as redactable */ rc_t col_defs_detect_redactable_cols_by_type( col_defs* defs, const VSchema * s, const matcher * m, const char * redactable_types ) { Vector id_vector; rc_t rc; if ( defs == NULL ) return RC( rcExe, rcNoTarg, rcResolving, rcSelf, rcNull ); if ( redactable_types == NULL ) return RC( rcExe, rcNoTarg, rcResolving, rcParam, rcNull ); VectorInit ( &id_vector, 0, 20 ); rc = redactable_types_2_type_id_vector( s, redactable_types, &id_vector ); if ( rc == 0 ) { uint32_t idx, len = VectorLength( &(defs->cols) ); for ( idx = 0; idx < len; ++idx ) { p_col_def col = (p_col_def) VectorGet ( &(defs->cols), idx ); if ( col != NULL ) if ( ! col->redactable ) col->redactable = matcher_src_has_type( m, s, col->name, &id_vector ); } VectorWhack ( &id_vector, type_id_ptr_whack, NULL ); } /* rc = nlt_make_namelist_from_string( &r_types, redactable_types ); if ( rc == 0 ) { uint32_t idx, len = VectorLength( &(defs->cols) ); for ( idx = 0; idx < len; ++idx ) { p_col_def col = (p_col_def) VectorGet ( &(defs->cols), idx ); if ( col != NULL ) if ( ! col->redactable ) col->redactable = matcher_src_has_type( m, col->name, r_types ); } KNamelistRelease( r_types ); } */ return rc; }
void vdcd_destroy( col_defs* defs ) { if ( defs == NULL ) return; VectorWhack( &(defs->cols), vdcd_destroy_node, NULL ); free( defs ); }
static void free_range( struct reference_range * self ) { VectorWhack ( &self->skip, release_skip, NULL ); free( self ); }
static void free_reference_region( struct reference_region * self ) { free( (void*)self->name ); VectorWhack ( &self->ranges, release_ranges_wrapper, NULL ); free( self ); }