Ejemplo n.º 1
0
ThreadProfiler::~ThreadProfiler() {
  FreeHeap(area_bottom);
  area_bottom = NULL;
  area_top = NULL;
  area_limit = NULL;
  FreeHeap(table);
  table = NULL;
}
  ~CodeBlobCollector() {
    if (_code_blobs != NULL) {
      for (int i=0; i<_code_blobs->length(); i++) {
	FreeHeap(_code_blobs->at(i));
      }
      delete _code_blobs;
    }
  }
Ejemplo n.º 3
0
/**
 * This routine is similar to FreeHeap in that it
 * deallocates the memory consumed by the heap.  However, it
 * also calls Deallocator for each item in the heap so that
 * this data is also deallocated.
 *
 * @param Heap heap whose data is to be freed
 * @param destructor function to be used to deallocate data
 *
 * Globals: 
 * - None
 *
 * @note Exceptions: none
 * @note History: Tue May 15 08:52:04 1990, DSJ, Created.
 */
void FreeHeapData(HEAP *Heap, void_dest destructor) {
  HEAPENTRY Entry;

  while (GetTopOfHeap (Heap, &Entry) != EMPTY)
    destructor (Entry.Data);

  FreeHeap(Heap);
}                                /* FreeHeapData */
Ejemplo n.º 4
0
void InliningDatabase::reset_lookup_table() {
  if (table) {
    FreeHeap(table);
    table           = NULL;
    table_size      = 0;
    table_size_mask = 0;
    table_no        = 0;
  }
}
Ejemplo n.º 5
0
void ArrayAllocator<E, F>::free() {
  if (_addr != NULL) {
    if (_use_malloc) {
      FreeHeap(_addr, F);
    } else {
      os::release_memory(_addr, _size);
    }
    _addr = NULL;
  }
}
Ejemplo n.º 6
0
int main ()
{
	int heapSize = 12;
	int intArray[4] = {4, 6, 2, 8};
	heapHndl testHeap, builtHeap;

	testHeap = NewHeap (heapSize);

	if (IsEmpty (testHeap))
	{
		printf ("working\n");
	}

	Insert (testHeap, 9);
	Insert (testHeap, 3);
	Insert (testHeap, 5);
	Insert (testHeap, 2);
	Insert (testHeap, 32);
	Insert (testHeap, 6);
	Insert (testHeap, 1);
	Insert (testHeap, 43);
	Insert (testHeap, 23);
	Insert (testHeap, 42);
	Insert (testHeap, 65);
	Insert (testHeap, 57);
	if (IsFull (testHeap))
	{
		printf ("heap currently full\n");
	}
	DeleteMax (testHeap);

	builtHeap = BuildHeap (5, intArray, 4);

	printf ("%d\n", MaxValue (testHeap));
	printf ("%d\n", MaxValue (builtHeap));

	FreeHeap (testHeap);
	FreeHeap (builtHeap);

	return 0;
}
Ejemplo n.º 7
0
 ~JvmtiGetLoadedClassesClosure() {
   JvmtiGetLoadedClassesClosure* that = get_this();
   assert(that != NULL, "JvmtiGetLoadedClassesClosure not found");
   set_this(NULL);
   _initiatingLoader = NULL;
   _count = 0;
   if (_list != NULL) {
     FreeHeap(_list);
     _list = NULL;
   }
   _index = 0;
 }
Ejemplo n.º 8
0
void EventLog::resize() {
  EL_Event* oldBuf = buf;
  EL_Event* oldEnd = bufEnd;
  EL_Event* oldNext = next;
  init();
  // copy events
  for (EL_Event* e = nextEvent(oldNext, oldBuf, oldEnd); e != oldNext;
       e = nextEvent(e, oldBuf, oldEnd), next = nextEvent(next, buf, bufEnd)) {
    *next = *e;
  }
  FreeHeap( oldBuf);
}
Ejemplo n.º 9
0
void EventLog::resize() {
  Event* oldBuf = buf;
  Event* oldEnd = bufEnd;
  Event* oldNext = next;
  init();
  // copy events
  for (Event* e = nextEvent(oldNext, oldBuf, oldEnd); e != oldNext;
       e = nextEvent(e, oldBuf, oldEnd), next = nextEvent(next, buf, bufEnd)) {
    *next = *e;
  }
  FreeHeap( oldBuf); // cant use delete because this is an array -- dmu
}
Ejemplo n.º 10
0
 bool set_value(char *value) {
   if (writeable()) {
     if (_value != NULL) {
       FreeHeap(_value);
     }
     _value = AllocateHeap(strlen(value)+1, mtInternal);
     if (_value != NULL) {
       strcpy(_value, value);
     }
     return true;
   }
   return false;
 }
Ejemplo n.º 11
0
void bootstrap::add(oop obj) {
  if (number_of_oops >= max_number_of_oops) {
    int new_size = max_number_of_oops  * 2;
    printf("Expanding boot table to %d\n", new_size);
    oop* new_oop_table = NEW_C_HEAP_ARRAY(oop, new_size);
    for(int index = 0; index < max_number_of_oops; index++)
      new_oop_table[index] = oop_table[index];

    max_number_of_oops = new_size;
    FreeHeap(oop_table);
    oop_table = new_oop_table;
  }
  oop_table[number_of_oops++] = obj;
}
Ejemplo n.º 12
0
NorlsAllocator::~NorlsAllocator()
{
#if NRLSTRACK
    g_NrlsAllocTracker->RemoveAllocator(this);
#if NRLSTRACK_GETSTACKS
    if (g_vbCommonHeap != TrackingHeapToUse ())
    {
//        VsDebHeapDestroy(TrackingHeapToUse (), true);
    }

#endif NRLSTRACK_GETSTACKS

#endif NRLSTRACK
    FreeHeap();
}
Ejemplo n.º 13
0
void
DisplayFatal(
    const char *szFilename,
    BOOL fDeleteFiles,
    UINT ErrorNumber,
    va_list valist
    )
{
    if (!fErr) {
        fErr = TRUE;

        // Close the PDB w/o committing.
        if (fPdb) {
            DBG_ClosePDB();
        }

        DisplayMessage(szFilename, FATALSTR, ErrorNumber, valist);

#ifdef ILINKLOG
        IlinkLog(GetExternalErrorCode(ErrorNumber)); // full link failures
#endif // ILINKLOG

        // free up memory reserved for ILK
        if (fINCR && fDeleteFiles) {
            FreeHeap();
        }

        FileCloseAll();
        RemoveConvertTempFiles();

        if (fDeleteFiles) {
            if (OutFilename != NULL && OutFilename[0] != '\0') {
                _unlink(OutFilename);
            }

            // in the incr case just blow away inc db which will
            // be in an invalid state
            if (fINCR && !_access(szIncrDbFilename, 0)) {
                _unlink(szIncrDbFilename);
            }
        }
    }

    exit((int) ErrorNumber);
}
Ejemplo n.º 14
0
void InliningDatabase::add_lookup_entry(LookupKey* outer, LookupKey* inner) {
  if (table_no * 2 >= table_size) {
    if (table == NULL) {
      allocate_table(4 * K);
    } else {
      // Expand table
      InliningDatabaseKey* old_table      = table;
      unsigned int         old_table_size = table_size;
      allocate_table(table_size * 2);
      for (unsigned int index = 0 ; index < old_table_size; index++) {
        if (old_table[index].is_filled())
	  add_lookup_entry(&old_table[index].outer, &old_table[index].inner);
      }
      FreeHeap(old_table);
    }
  }
  assert(table_no * 2 < table_size, "just checking density");
  
  unsigned int index = index_for(outer, inner);

  while (table[index].is_filled()) {
    if (table[index].equal(outer, inner)) return;
    index = next_index(index);
  }

  table[index].outer = *outer;
  if (inner) {
    table[index].inner = *inner;
  }
  table_no++;

  if (TraceInliningDatabase) {
    std->print_cr("InliningDatabase::add_lookup_entry @ %d", index);
    if (inner) {
      inner->print();
      std->print(" ");
    }
    outer->print();
    std->cr();
  }
}
Ejemplo n.º 15
0
 void append_value(const char *value) {
   char *sp;
   size_t len = 0;
   if (value != NULL) {
     len = strlen(value);
     if (_value != NULL) {
       len += strlen(_value);
     }
     sp = AllocateHeap(len+2, mtInternal);
     if (sp != NULL) {
       if (_value != NULL) {
         strcpy(sp, _value);
         strcat(sp, os::path_separator());
         strcat(sp, value);
         FreeHeap(_value);
       } else {
         strcpy(sp, value);
       }
       _value = sp;
     }
   }
 }
Ejemplo n.º 16
0
static void releaseData(void* info, const void* data, size_t size) {
  FreeHeap((void*)data);
}
Ejemplo n.º 17
0
Archivo: ucl.c Proyecto: M-ike/work
static void Finalize(void)
{
	FreeHeap(&FileHeap);
}
Ejemplo n.º 18
0
/* 结束 */
static void Finalize (void) 
{
    /* 释放文件堆 */
    FreeHeap (&FileHeap);
}
Ejemplo n.º 19
0
OSStatus ATSUDisposeTextLayout_wrap(ATSUTextLayout lay) {
  void* oText;
  OSStatus e = ATSUGetTextLocation(lay, &oText, NULL, NULL, NULL, NULL);
  if (!e)  FreeHeap(oText);
  return ATSUDisposeTextLayout(lay);
}
Ejemplo n.º 20
0
void MallocArrayAllocator<E, F>::free(E* addr, size_t /*length*/) {
  FreeHeap(addr);
}
Ejemplo n.º 21
0
ResourceAreaChunk::~ResourceAreaChunk() {
  FreeHeap(bottom);
}
Ejemplo n.º 22
0
void CHeapObj::operator delete(void* p){
 assert( !resources.contains((char*)p),
        "CHeapObj should not be in resource area");
 FreeHeap(p);
}
Ejemplo n.º 23
0
template <MEMFLAGS F> void CHeapObj<F>::operator delete [](void* p){
    FreeHeap(p, F);
}
Ejemplo n.º 24
0
bootstrap::~bootstrap() {
  FreeHeap(oop_table);
}
Ejemplo n.º 25
0
/* The heap is being destroyed. Free everything if
 * not done already.
 */
MEMHEAP::~MEMHEAP()
{
    FreeHeap();
}
Ejemplo n.º 26
0
size_t WeightedMatching(RowStarts *rowptr,ColIndices *colind,ValueType *C,
ValueType *C1,ValueType *dist,ValueType *u,ValueType *v,Indices *p,
Indices *m_inv,Indices *m, Indices n,CompareFunction cmpFunc){

	size_t i,j,i1,jend,k,m_inv_prev;
	size_t match_size=0;
	ValueType curr_shortest_path = (ValueType)0;
	ValueType curr_aug_path = GetMaxTypeValue<ValueType>(); 
	ValueType dist1; Indices itrace;
	BitArray_t *col_marker = CreateBitArray(n);
	BitArray_t *heap_marker = CreateBitArray(n);
	C--;m--;C1--;dist--;u--;v--;p--;m_inv--;
	rowptr--;colind--;
#if BINARY_HEAP
	Heap *bin_heap = NewBinaryHeap(cmpFunc,n,GetDistKeyID);  
	ValueType *dist_ptr = NULL;
#endif
	assert(C1 && dist && u && v && p);
	ComputeInitialExtremeMatch<ValueType,Indices>(u,v,C1,C,m,m_inv,colind,rowptr,n,dist);
	match_size=0;
	for(i=1;i<=n;i++){
		if(m_inv[i]){
			match_size++;
			continue;
		}
		/*
		 *Aim is to find a value for jend such that the path
		 *from i-->jend is the shortest
		 */
		i1 = i; p[i1] = 0; jend=0; itrace=i;
		ResetAllBits(col_marker);
		ResetAllBits(heap_marker);
#if BINARY_HEAP
		bin_heap->n = 0;
		dist_base = (unsigned long)&(dist[1]);
#endif
		curr_shortest_path=(ValueType)0;
		curr_aug_path=GetMaxTypeValue<ValueType>();
		while(1){
			for(k=rowptr[i1];k<rowptr[i1+1];k++){
				j = colind[k];
				if(CheckBit(col_marker,j)){
					continue;
				}
				dist1 = curr_shortest_path + C1[k];
				/*Prune any dist1's > curr_aug_path, since
				 *all the costs>0 
				 */
				if(*((long long int *)&dist1) < *((long long int *)&curr_aug_path)){
					if(!m[j]){
						/*we need itrace because, the last i1 which
						 *we explore may not actually give the shortest 
						 *augmenting path.*/
						jend = j; itrace = i1;
						curr_aug_path = dist1;
					}else if(*((long long int *)&dist1) < *((long long int *)&(dist[j]))){ 
						/*Update the dist*/
						dist[j] = dist1; p[m[j]] = i1;
#if SIMPLE_HEAP
						SetBit(heap_marker,j);
#elif BINARY_HEAP
						if(CheckBit(heap_marker,j)){
							DecreaseKey(bin_heap,j);
						}else{
							InsertHeap(bin_heap,&(dist[j]));
							SetBit(heap_marker,j);
						}
#endif
					}
				}
			}
			if(*((long long int *)&curr_aug_path) <= *((long long int *)&curr_shortest_path)){ 
				break;
			}
			/*We now have a heap of matched cols, so pick the min*/
#ifdef SIMPLE_HEAP
			j = SimplePickMin(heap_marker,dist,n);
			if(j){
				curr_shortest_path = dist[j]; 
				UnsetBit(heap_marker,j); 
#elif BINARY_HEAP
			dist_ptr = (ValueType *) HeapDelete(bin_heap);
			if(dist_ptr){
				assert((unsigned long)dist_ptr >= (unsigned long)&dist[1]);
				j = ((((unsigned long)dist_ptr -
					(unsigned long)&dist[1]))/sizeof(double))+1;
				assert(j>=1 && j<=n);
				curr_shortest_path = dist[j]; 
				UnsetBit(heap_marker,j); 
#endif
				SetBit(col_marker,j);
				i1 = m[j];
			}else{
				break;
			}
		}
		if(jend){ /*We found a shortest augmenting path*/
			j=jend;
			node_t itrace_prev;
			//printf("Shortest augmenting Path {");
			while(itrace){
				m_inv_prev = m_inv[itrace];
				m[j] = itrace; m_inv[itrace]=j;
				//printf("(%u,%u)",itrace,j);
				j=m_inv_prev;
				itrace_prev = itrace;
				itrace = p[itrace];
				if(itrace){
				//	printf("(%u,%u)",itrace_prev,m_inv_prev);
				}
			}
			match_size++;
			//printf("}\n");
			/*Update the cost with new match m*/
			for(j=1;j<=n;j++){
				if(CheckBit(col_marker,j)){
					u[j] = (u[j]+dist[j])-curr_aug_path;
					/*Reset the dist values*/
				}
			}
			for(i1=1;i1<=n;i1++){
				if(!m_inv[i1]) continue;
				j = m_inv[i1];
				for(k=rowptr[i1];k<rowptr[i1+1];k++){
					if(colind[k] == j){
						v[i1] = C[k] - u[j];
					}
				}
			}
			/*Update the cost*/
			for(i1=1;i1<=n;i1++){
				for(k=rowptr[i1];k<rowptr[i1+1];k++){
					j = colind[k];
					C1[k] = C[k]-(u[j]+v[i1]);
				}
				/*The index should be j rather than i1 but just 
				 *avoiding another loop*/
				dist[i1] = GetMaxTypeValue<double>();
			}
		}
	}
	FreeBitArray(col_marker);
	FreeBitArray(heap_marker);
#ifdef BINARY_HEAP	
	FreeHeap(bin_heap);
#endif

	return match_size;
}
/*O(n) time picking the maximum from the heap_marker */
node_t SimplePickMin(BitArray_t *bit_heap,double *dist,node_t n){
	node_t min_j=0;node_t j; 
	double curr_min = MAX_DOUBLE_VALUE; 
	for(j=1;j<=n;j++){
		if(CheckBit(bit_heap,j) && dist[j] < curr_min){
			min_j = j;
			curr_min = dist[j];
		}
	}
	return min_j;
}
Ejemplo n.º 27
0
MonitorChunk::~MonitorChunk() {
  FreeHeap(monitors());
}
Ejemplo n.º 28
0
void  MemRegion::operator delete [](void* p) {
  FreeHeap(p, mtGC);
}
Ejemplo n.º 29
0
void CHeapObj::operator delete(void* p){
 FreeHeap(p);
}
Ejemplo n.º 30
0
size_t WeightedMatching(RowStarts rowptr,ColIndices colind,ValueTypePtr C,
ValueTypePtr dist,ValueTypePtr u,ValueTypePtr v,Indices *p,
Indices *m_inv,Indices *m, Indices n,CompareFunction cmpFunc){
	typedef typename std::iterator_traits<ValueTypePtr>::value_type ValueType;
	Indices i,j,i1,jend,k,m_inv_prev;
	Indices match_size=0; Indices k0,j0;
	ValueType curr_shortest_path = (ValueType)0;
	ValueType curr_aug_path = GetMaxTypeValue<ValueType>(curr_aug_path); 
	ValueType dist1; Indices itrace;
	/*Cost of the edges in the match if
	 *$(i,j) \in M$ then $clabel[i] = C[i][j]$*/
	Indices *clabel = new Indices[n];
	Indices *aug_label = new Indices[n];
	Indices *update_stack = new Indices[n];
	Indices update_stack_index;
	/*Save The Operations on the Heap.*/
	Indices save_heap_index;
	Indices *save_heap_op = new Indices[n];
#ifdef TURN_ON_SAVE_HEAP
	double close_factor = (double)1.0 + (double)1.0e-16;
#endif
	/*Force the write back to memory to avoid floating point issues*/
	ValueType force_mem_write[3];
#ifndef NO_LOCAL_PROFILING
	CreateProfilingClocks();
#endif

	/*Core Profiling Clock*/
	Clock *core_clk = CreateClock();
#ifdef USE_BIT_ARRAY
	BitArray_t *col_marker = CreateBitArray(n);
	BitArray_t *heap_marker = CreateBitArray(n);
#else
	Indices *col_marker = new Indices[n];
	unsigned int *heap_marker = NULL;
	col_marker--;
	for(i=1;i<=n;i++){ /*Do we need Initialization?*/
		col_marker[i] = (Indices)0;
	}
#endif
#if BINARY_HEAP
	Heap *bin_heap = NewBinaryHeap(cmpFunc,n,GetDistKeyID);  
	ValueType *dist_ptr = NULL;
	heap_marker = bin_heap->keyMap;
#endif
	/*Algorithm Uses 1-Indexing to be consistent*/
	C--;m--;dist--;u--;v--;p--;m_inv--;
	rowptr--;colind--;clabel--;save_heap_op--;
	update_stack--;aug_label--;
	assert(dist && u && v && p);
	ComputeInitialExtremeMatch<ValueType,Indices>(u,v,clabel,C,m,m_inv,colind,
		rowptr,n,dist);
	match_size=0; 

	StartClock(core_clk);

	for(i=1;i<=n;i++){
		if(m_inv[i]){
			match_size++;
			continue;
		}
		/*
		 *Aim is to find a value for jend such that the path
		 *from i-->jend is the shortest
		 */
		i1 = i; p[i1] = 0; jend=0; itrace=i;
#ifdef USE_BIT_ARRAY
		ResetAllBits(col_marker);
		ResetAllBits(heap_marker);
#endif

#if BINARY_HEAP
		bin_heap->n = 0;
		dist_base = (unsigned long)&(dist[1]);
#endif
		curr_shortest_path=(ValueType)0;
		curr_aug_path=GetMaxTypeValue<ValueType>(curr_aug_path);
		save_heap_index = (Indices)0;
		update_stack_index = (Indices)0;
		while(1){
			for(k=rowptr[i1]+1;k<(rowptr[i1+1]+1);k++){ 
				j = colind[k]+1; 
#ifdef USE_BIT_ARRAY
				if(CheckBit(col_marker,j)){
#else
				if(col_marker[j]==i){
#endif
					continue;
				}
				force_mem_write[k%3] = C[k]-(v[i1]+u[j]);
				dist1 = curr_shortest_path + force_mem_write[k%3];
				/*Prune any dist1's > curr_aug_path, since
				 *all the costs>0 
				 */
				if(dist1 < curr_aug_path){
					if(!m[j]){
						/*we need itrace because, the last i1 which
						 *we explore may not actually give the shortest 
						 *augmenting path.*/
						jend = j; itrace = i1;
						curr_aug_path = dist1;
						aug_label[j] = k;
					}else if(dist1 < dist[j]){ 
						/*Update the dist*/
						dist[j] = dist1; p[m[j]] = i1;
						aug_label[j] = k;
#if SIMPLE_HEAP

#ifdef USE_BIT_ARRAY
						SetBit(heap_marker,j);
#else
						heap_marker[j] = i;
#endif

#elif BINARY_HEAP /*SIMPLE_HEAP*/

#ifdef USE_BIT_ARRAY
						if(CheckBit(heap_marker,j)){
#else
						if(heap_marker[j]){
#endif
#ifndef NO_LOCAL_PROFILING
							StartClock(hupdate_clk);
#endif
							/*Call the decrease Key Operation*/
							DecreaseKey(bin_heap,j);

#ifndef NO_LOCAL_PROFILING
							StopClock(hupdate_clk);
							hupdate_ticks += GetClockTicks(hupdate_clk);
#endif
						}
#ifdef TURN_ON_SAVE_HEAP 
						else if(curr_shortest_path &&  
							dist[j] <= (curr_shortest_path)*(close_factor)){
							/*If dist[j] is close to root push it in
							 *save_heap_op*/
							 assert(save_heap_index < n);
							 save_heap_op[++save_heap_index] = j;
						}
#endif					
						else{
#ifndef NO_LOCAL_PROFILING
							StartClock(hins_clk);
#endif
							InsertHeap(bin_heap,&(dist[j]));
#ifndef NO_LOCAL_PROFILING
							StopClock(hins_clk);
							hins_ticks += GetClockTicks(hins_clk);
#endif
#ifdef USE_BIT_ARRAY
							SetBit(heap_marker,j);
#endif
						}
#endif /*SIMPLE_HEAP*/
					}
				}
			}
			if(curr_aug_path <= curr_shortest_path){ 
				break;
			}
			/*We now have a heap of matched cols, so pick the min*/
#ifdef SIMPLE_HEAP
			j = SimplePickMin(heap_marker,dist,n);
			if(j){
				curr_shortest_path = dist[j]; 
				UnsetBit(heap_marker,j); 
#elif BINARY_HEAP


#ifndef NO_LOCAL_PROFILING
			StartClock(hdel_clk);
#endif
			if(save_heap_index){
				j = save_heap_op[save_heap_index];
				save_heap_index--;
				curr_shortest_path = dist[j]; 
#ifdef USE_BIT_ARRAY
				SetBit(col_marker,j);
#else
				col_marker[j] = (Indices)i;
				update_stack[++update_stack_index]=j;
#endif /*#ifdef USE_BIT_ARRAY*/

				i1 = m[j];
			}else if(dist_ptr = (ValueType *) HeapDelete(bin_heap)) {
#ifndef NO_LOCAL_PROFILING
				StopClock(hdel_clk);
				hdel_ticks += GetClockTicks(hdel_clk);
#endif
				assert((unsigned long)dist_ptr >= (unsigned long)&dist[1]);
				j = ((((unsigned long)dist_ptr -
					(unsigned long)&dist[1]))/sizeof(ValueType))+1;
				assert(j>=1 && j<=n);
				curr_shortest_path = dist[j]; 
				heap_marker[j] = 0; /*Setting the keyMap in Heap to 0*/
#endif /*#ifdef SIMPLE_HEAP */


#ifdef USE_BIT_ARRAY
				SetBit(col_marker,j);
				update_stack[++update_stack_index]=j;
#else
				col_marker[j] = (Indices)i;
				update_stack[++update_stack_index]=j;
#endif /*#ifdef USE_BIT_ARRAY*/

				i1 = m[j];
			}else{
				break;
			}
		}
		/*We found a shortest augmenting path*/
		if(jend){ 
			unsigned long **harray = bin_heap->heapArray;
#ifndef NO_LOCAL_PROFILING
			StartClock(dual_clk);
#endif
			/*NOTE1: We need a very fast way to update
			 *the dual variables and also reset the dist[]
			 *we avoid linear scan where ever we can to update
			 *these dual variables*/
			while(update_stack_index){ /*Update u[j]: while*/
				j=update_stack[update_stack_index--];
				u[j] = (u[j]+dist[j])-curr_aug_path;
				if(m[j]){ /*See NOTE1*/
					i1 = m[j];
					v[i1] = C[clabel[i1]] - u[j];
				}
				dist[j] = MAX_DOUBLE_VALUE;
				if(bin_heap->n){
					dist_ptr = (double *)harray[bin_heap->n];
					j = ((((unsigned long)dist_ptr -
						(unsigned long)&dist[1]))/sizeof(ValueType))+1;
					heap_marker[j] = 0;
					*((double *)harray[bin_heap->n]) = MAX_DOUBLE_VALUE;
					bin_heap->n -= 1 ;
				}
			} /*Update u[j]: while*/
			
			/*Uncomment if you need to print augmenting path*/
			/*node_t itrace_prev;*/
			/*printf("Shortest augmenting Path {");*/

			j=jend;
			while(itrace){
				m_inv_prev = m_inv[itrace];
				m[j] = itrace; m_inv[itrace]=j;
				/*See NOTE1(above)*/
				clabel[itrace] = aug_label[j];
				v[itrace] = C[clabel[itrace]] - u[j];
				/*printf("(%u,%u)",itrace,j);*/
				j=m_inv_prev;
				/*itrace_prev = itrace;*/
				itrace = p[itrace];
				/*
				if(itrace){
					printf("(%u,%u)",itrace_prev,m_inv_prev);
				}*/
			}
			/*printf("}\n");*/
			/*There may some dist[] still in the heap*/
			while(bin_heap->n){
				dist_ptr = (double *)harray[bin_heap->n];
				j = ((((unsigned long)dist_ptr -
					(unsigned long)&dist[1]))/sizeof(ValueType))+1;
				heap_marker[j] = 0;
				*((double *)harray[bin_heap->n]) = MAX_DOUBLE_VALUE;
				bin_heap->n -= 1;
			}
			match_size++;
			/*End Dual Update*/
#ifndef NO_LOCAL_PROFILING
			StopClock(dual_clk);
			dual_ticks += GetClockTicks(dual_clk);
#endif
		} /*if(jend) : Found Augmeting Path*/
	} /*for(i=1;i<=n;i++): Main Outer Loop*/

	StopClock(core_clk);
	WeightedMatchTicks = GetClockTicks(core_clk);

#ifndef NO_LOCAL_PROFILING
	printf("Profile Summary\n");
	printf("HINS=(%d) HDEL=(%d) HUPDATE=(%d)\n",(int)hins_ticks,(int)hdel_ticks,
		(int)hupdate_ticks);
	printf("DUAL=(%d) \n",(int)dual_ticks);
#endif

#ifdef USE_BIT_ARRAY
	FreeBitArray(col_marker);
	FreeBitArray(heap_marker);
#else
	col_marker++;
	delete col_marker; 
#endif

#ifdef SIMPLE_HEAP
	heap_marker++;
	delete heap_marker;
#endif

	aug_label++;
	delete aug_label;
	save_heap_op++;
	delete save_heap_op;
	clabel++;
	delete clabel;
#ifdef BINARY_HEAP	
	FreeHeap(bin_heap);
#endif
	return match_size;
}
/*O(n) time picking the maximum from the heap_marker */
node_t SimplePickMin(BitArray_t *bit_heap,double *dist,node_t n){
	node_t min_j=0;node_t j; 
	double curr_min = HUGE_VAL; 
	for(j=1;j<=n;j++){
		if(CheckBit(bit_heap,j) && dist[j] < curr_min){
			min_j = j;
			curr_min = dist[j];
		}
	}
	return min_j;
}
#ifdef BINARY_HEAP 
inline keyid_t GetDistKeyID(void *dist_ptr){ assert((unsigned long)dist_ptr >= dist_base);
	return (((((unsigned long)dist_ptr-dist_base))/sizeof(double))+1);
}
#endif

BitArray_t* CreateBitArray(unsigned int size){
	div_t d = div(size,SIZE_OF_BYTE_IN_BITS);
	BitArray_t *bits = (BitArray_t *)malloc(sizeof(BitArray_t)*1);
	assert(bits);
	bits->size = (d.rem > 0)?(d.quot+1):d.quot;
	bits->ba = (char *)malloc(sizeof(char)*(bits->size));
	assert(bits->ba);
	memset(bits->ba,'\0',bits->size);
	return bits;
}