/* * We only support unmapping the whole segment, and we automatically unlock * what we previously soft-locked. */ static int segmf_unmap(struct seg *seg, caddr_t addr, size_t len) { struct segmf_data *data = seg->s_data; offset_t off; if (addr < seg->s_base || addr + len > seg->s_base + seg->s_size || (len & PAGEOFFSET) || ((uintptr_t)addr & PAGEOFFSET)) panic("segmf_unmap"); if (addr != seg->s_base || len != seg->s_size) return (ENOTSUP); hat_unload(seg->s_as->a_hat, addr, len, HAT_UNLOAD_UNMAP | HAT_UNLOAD_UNLOCK); off = (offset_t)seg_page(seg, addr); ASSERT(data->vp != NULL); (void) VOP_DELMAP(VTOCVP(data->vp), off, seg->s_as, addr, len, data->prot, data->maxprot, MAP_SHARED, CRED(), NULL); seg_free(seg); return (0); }
/* * Free segment list. */ void seg_list_free(asseg_t *p) { asseg_t *next = NULL, *curr = p; while (curr) { next = curr->next; seg_free(curr); curr = next; } }
// Free a LinkedIDList and all structures associated with it. void lil_free(LinkedIDList * lil) { LinkedIDList * next; while ( lil != NULL) { next = lil->next; if (lil->firstSegment != NULL) { seg_free(lil->firstSegment); } free(lil); if (next == NULL) { break; } lil = next; } lil = NULL; }
/* * Create a segment with the specified attributes. */ asseg_t *seg_create(char *name, float st, float et, float score) { asseg_t *p; if ((p = (asseg_t *)malloc(sizeof(asseg_t))) == NULL) { fprintf(stderr, "seg_create() -- unable to allocate %d bytes\n", sizeof(asseg_t)); return(NULL); } p->label = (seglab_t *)NULL; p->st = st; p->et = et; p->score = score; p->next = p->prev = NULL; if (name) { if ((p->label = str_to_label(name)) == NULL) { fprintf(stderr, "seg_create() -- cannot set segment label\n"); seg_free(p); } } return(p); }