static int Zoltan_Oct_Update_Map(ZZ *zz) { int i; double x,y; pRList RootList; pOctant RootOct; pOctant remoteoctant; Migrate_msg *rootlists = NULL; OCT_Global_Info *OCT_info = (OCT_Global_Info *)(zz->LB.Data_Structure); Map *array = OCT_info->map; int mapsize = OCT_info->mapsize; int rlsize = 0; int ierr = ZOLTAN_OK; char *yo = "Zoltan_Oct_Update_Map"; if((ierr = Zoltan_Oct_build_global_rootlist(zz, &rootlists, &rlsize)) != ZOLTAN_OK) { ZOLTAN_TRACE_EXIT(zz, yo); return ierr; } for(i = 0; i < mapsize; i++) { RootList = array[i].list; while((RootOct = RL_nextRootOctant(&RootList))) { Zoltan_Oct_free(OCT_info, &RootOct); /* KDDKDDFREE set oct pointer of RootList to NULL. */ RootList->oct = NULL; } RL_clearRootOctants(&(array[i].list)); } for(i = 0; i < rlsize; i++) { remoteoctant = Zoltan_Oct_newremote(); remoteoctant->remoteptr = rootlists[i].ptr; x = rootlists[i].max[0] - rootlists[i].min[0]; y = rootlists[i].max[1] - rootlists[i].min[1]; remoteoctant->area = x*y; remoteoctant->ppid = rootlists[i].ppid; remoteoctant->npid = rootlists[i].from; Zoltan_Oct_setID(remoteoctant,rootlists[i].id); Zoltan_Oct_setchildnum(remoteoctant,rootlists[i].childnum); Zoltan_Oct_setchildren(remoteoctant, rootlists[i].children, rootlists[i].cpids); Zoltan_Oct_setbounds(remoteoctant, rootlists[i].min, rootlists[i].max); Zoltan_Oct_setDir(remoteoctant,rootlists[i].dir); Zoltan_Oct_setMapIdx(remoteoctant,rootlists[i].mapidx); RL_addRootOctant(array[Zoltan_Oct_mapidx(remoteoctant)].list, remoteoctant); } if(rlsize > 0) ZOLTAN_FREE(&rootlists); return ierr; }
void Zoltan_Oct_Free_Structure(ZZ *zz) { /* * Deallocate the persistent OCT data structures in zz->Structure. */ OCT_Global_Info *OCT_info = (OCT_Global_Info *) (zz->LB.Data_Structure); pRList RootList; /* list of all local roots */ pOctant RootOct; int i; if (OCT_info != NULL) { /* free octree */ /* KDDKDD In distribution from RPI, the following frees were commented out. * KDDKDD I do not think they should be commented out, as Debug_Memory * KDDKDD reports lots of memory leaks. * KDDKDD I have un-commented them. 12/2000 */ /* KDDKDDFREE Rearranged the frees because the global octants were trying to * KDDKDDFREE access children that were already deleted in Zoltan_Oct_POct_delTree. * KDDKDDFREE Now delete global octants first, then the tree. 1/2001 */ /* free global octants */ for(i = 0; i < OCT_info->mapsize; i++) { RootList = OCT_info->map[i].list; while((RootOct = RL_nextRootOctant(&RootList))) { Zoltan_Oct_free(OCT_info, &RootOct); /* KDDKDDFREE Set RootList's oct ptr to NULL as the octant is deleted.*/ RootList->oct = NULL; } RL_freeList(&(OCT_info->map[i].list)); } /* free map array */ ZOLTAN_FREE(&(OCT_info->map)); /* Free the octree */ RootList = Zoltan_Oct_POct_localroots(OCT_info); while ((RootOct = RL_nextRootOctant(&RootList))){ /* KDDKDDFREE The Zoltan_Oct_POct_delTree also frees RootList, since * KDDKDDFREE Zoltan_Oct_POct_free frees the root list entry for root octants. * KDDKDDFREE Need to reset RootList in each iteration. */ Zoltan_Oct_POct_delTree(OCT_info, &RootOct); RootList = Zoltan_Oct_POct_localroots(OCT_info); } RL_freeList(&(OCT_info->OCT_rootlist)); /* KDDKDD End of previously commented-out section. 12/2000 */ ZOLTAN_FREE(&(zz->LB.Data_Structure)); } }
/* KDDKDDFREE Changed oct to *oct to allow NULL from ZOLTAN_FREE to propagate back * KDDKDDFREE to the calling routine. */ void Zoltan_Oct_POct_free(OCT_Global_Info *OCT_info, pOctant *oct) { /* KDDKDDFREE This variable no longer needed. pRList RootList = Zoltan_Oct_POct_localroots(OCT_info); * KDDKDDFREE */ /* traverse through local root list, if octant a local root */ if(Zoltan_Oct_Ppid(*oct) != OCT_info->OCT_localpid) { /* KDDKDDFREE Now passing pointer to OCT_rootlist so that, if * KDDKDDFREE head of list is deleted, this pointer can be updated * KDDKDDFREE appropriately (i.e., no longer points to deleted entry). */ RL_delRootOctant(OCT_info, &(OCT_info->OCT_rootlist), *oct); } /* free up space in memory */ Zoltan_Oct_free(OCT_info, oct); }