void aspace_destroy(aspace_t *a) { area_t *area; /* tear down all attached areas */ while((area = (area_t*) list_peek_head(&a->areas))){ area_destroy(a, area->rsrc.id); } rsrc_release(&a->rsrc); /* release page directory and table(s) */ kfreepage(a->pdir); kfreepage(a->ptab); kfree(aspace_t, a); }
void column_detach(Frame *f) { Frame *first; Area *a; int dy; a = f->area; stack_info(f, &first, nil, &dy, nil); if(first && first == f) first = f->anext; column_remove(f); if(a->frame) { if(first) stack_scale(first, dy); column_arrange(a, false); }else if(a->view->areas[a->screen]->next) area_destroy(a); }
/* test functions */ static int test_area (AREA_CREATE_INFO * info, int nthreads, void *(*proc) (void *)) { #define MAX_THREADS 64 AREA *area = NULL; pthread_t threads[MAX_THREADS]; char msg[256]; int i; assert (info != NULL); sprintf (msg, "%s(size:%d, count:%d), %d threads", info->name, info->entry_size, info->alloc_cnt, nthreads); begin (msg); /* initialization */ if (nthreads > MAX_THREADS) { return fail ("too many threads"); } /* initialization */ area_init (); area = area_create (info->name, info->entry_size, info->alloc_cnt); if (area == NULL) { return fail ("area create fail"); } /* multithreaded test */ for (i = 0; i < nthreads; i++) { if (pthread_create (&threads[i], NULL, proc, (void *) area) != NO_ERROR) { return fail ("thread create"); } } for (i = 0; i < nthreads; i++) { void *retval; pthread_join (threads[i], &retval); if (retval != NO_ERROR) { return fail ("thread proc error"); } } /* results */ { AREA_BLOCKSET_LIST *blockset; AREA_BLOCK *block; int i, j, blockset_cnt = 0, block_cnt = 0, chunk_count; for (blockset = area->blockset_list; blockset != NULL; blockset = blockset->next) { for (i = 0; i < blockset->used_count; i++) { block = blockset->items[i]; assert (block != NULL); chunk_count = CEIL_PTVDIV (block->bitmap.entry_count, LF_BITFIELD_WORD_SIZE); for (j = 0; j < chunk_count; j++) { if (block->bitmap.bitfield[j]) { return fail ("check bitmap status"); } } block_cnt++; } blockset_cnt++; } printf (" Used %3d blocks(%2d blocksets). ", block_cnt, blockset_cnt); } /* destory */ area_destroy (area); area_final (); return success (); #undef MAX_THREADS }