/*
* ion/ioncore/mplexpholder.c
*
- * Copyright (c) Tuomo Valkonen 2005-2007.
+ * Copyright (c) Tuomo Valkonen 2005-2009.
*
* See the included file LICENSE for details.
*/
UNLINK_ITEM(ph->after->phs, ph, next, prev);
}else if(mplex!=NULL && on_ph_list(mplex->misc_phs, ph)){
UNLINK_ITEM(mplex->misc_phs, ph, next, prev);
- }else{
+ }else if(ph->prev!=NULL){
WMPlexPHolder *next=ph->next;
-
- if(ph->prev!=NULL)
- ph->prev->next=next;
+
+ ph->prev->next=next;
if(next==NULL){
next=get_head(ph);
assert(next->prev==ph);
}
next->prev=ph->prev;
+ }else{
+ /* ph should not be on a list, if prev pointer is NULL (whereas
+ * next alone can be NULL in our semi-doubly-linked lists).
+ */
+ assert(ph->next==NULL);
}
ph->after=NULL;
WRegionAttachData data2;
WFramedPHolder *fph;
WPHolder *root;
- WRegion *frame;
+ WRegion *res;
RP rp;
rp.ph_head=get_head(ph);
data2.u.n.fn=recreate_handler;
data2.u.n.param=&rp;
- frame=pholder_do_attach(fph->cont, flags, &data2);
+ res=pholder_do_attach(fph->cont, flags, &data2);
- if(frame!=NULL){
+ if(res!=NULL){
rp.ph_head->recreate_pholder=NULL;
/* It might be in use in attach chain! So defer. */
mainloop_defer_destroy((Obj*)fph);
}
- return rp.reg_ret;
+ return (flags&PHOLDER_ATTACH_RETURN_CREATEROOT
+ ? (WRegion*)res
+ : rp.reg_ret);
}