static void rr_store_release ( rr_store * rr ) { if ( rr != NULL ) { KVectorVisitPtr( rr->v, false, rr_entry_release, NULL ); KVectorRelease ( rr->v ); free( ( void * ) rr ); } }
static rc_t save_store( struct sorter * sorter ) { rc_t rc = 0; if ( sorter->bytes_in_store > 0 ) { char buffer[ 4096 ]; struct lookup_writer * writer; if ( sorter->params.mem_limit > 0 ) { rc = make_subfilename( &sorter->params, sorter->sub_file_id, buffer, sizeof buffer ); if ( rc == 0 ) sorter->sub_file_id++; } else rc = make_dst_filename( &sorter->params, buffer, sizeof buffer ); if ( rc == 0 ) rc = make_lookup_writer( sorter->params.dir, NULL, &writer, sorter->params.buf_size, "%s", buffer ); if ( rc == 0 ) { rc = KVectorVisitPtr( sorter->store, false, on_store_entry, writer ); release_lookup_writer( writer ); } if ( rc == 0 ) { sorter->bytes_in_store = 0; rc = KVectorRelease( sorter->store ); if ( rc != 0 ) ErrMsg( "KVectorRelease() -> %R", rc ); else { sorter->store = NULL; rc = KVectorMake( &sorter->store ); if ( rc != 0 ) ErrMsg( "KVectorMake() -> %R", rc ); } } } return rc; }