Esempio n. 1
0
/*
 * rnodeUnlink
 * Unlink a node from the tree.
 */
static void
rnodeUnlink (meRegNode *np)
{
    /* Link to the parent. */
    meRegNode *pnp;

    pnp = np->parent;                     /* Get the parent out */

    if (pnp->child == np)
        pnp->child = np->next;
    else
    {
        pnp = pnp->child;                /* Descend child to head */
        while (pnp->next != np)         /* Find sibling in list */
        {
            pnp = pnp->next;
            meAssert (pnp != NULL);
        }
        pnp->next = np->next;           /* Unlink the sibling */
    }

    /* Fix up the root and sibling pointers */
    np->next = NULL;
    np->parent = NULL;
}
Esempio n. 2
0
File: frame.c Progetto: collects/me
/* initialize a frame, mallocing required video and framestore space.
 *
 * The frame depthMax and widthMax must be set */
meFrame *
meFrameInit(meFrame *sibling)
{
    meFrame *frame ;
    meFrameLine *flp;                     /* Frame store line pointer */
    int ii, jj ;                        /* Local loop counters */

    /* add 2 to hilBlockS to allow for a double trunc-scheme change */
    if((frame = meMalloc(sizeof(meFrame))) == NULL)
        return NULL ;
    memset(frame,0,sizeof(meFrame)) ;

#if MEOPT_FRAME
    if(sibling != NULL)
    {
        frame->mainId = sibling->mainId ;
        frame->width = sibling->width ;
        frame->depth = sibling->depth ;
        frame->widthMax = sibling->widthMax ;
        frame->depthMax = sibling->depthMax ;
    }
    else
#else
    meAssert(sibling == NULL) ;
#endif
    {
        frame->mainId = 0 ;
#if MEOPT_FRAME
        {
            meFrame *ff = frameList ;
            while(ff != NULL)
            {
                if(ff->mainId == frame->mainId)
                {
                    if(frame->mainId == 255)
                    {
                        free(frame) ;
                        return NULL ;
                    }
                    frame->mainId++ ;
                    ff = frameList ;
                }
                ff = ff->next ;
            }
        }
#endif
        frame->width = TTwidthDefault ;
        frame->depth = TTdepthDefault-1 ;
        frame->widthMax = TTwidthDefault ;
        frame->depthMax = TTdepthDefault ;
    }
    if(meFrameTermInit(frame,sibling) <= 0)
        return NULL ;

    if(((frame->video.lineArray = meMalloc(frame->depthMax * sizeof(meVideoLine))) == NULL) ||
            ((frame->mlLine = meLineMalloc(frame->widthMax,0)) == NULL) ||
            ((frame->mlLineStore = meMalloc(frame->widthMax+1)) == NULL))
        return NULL ;

    /* Initialise the virtual video structure. */
    memset(frame->video.lineArray,0,frame->depthMax*sizeof(meVideoLine)) ;
    frame->video.lineArray[frame->depth].flag = VFMESSL ;
    frame->video.lineArray[frame->depth].line = frame->mlLine ;
    /* Reset the video list block */
    frame->video.next = NULL;                 /* No next block */
    frame->video.window = NULL;               /* No windows attached */

    memset(frame->mlLine->text,'\0',frame->widthMax) ;
    frame->mlLineStore[0] = '\0';
#if MEOPT_EXTENDED
    frame->id = ++nextFrameId ;
#endif

    /* Frame Store storage
     * The frame store hold's 'n' lines of video information.
     * The frame->store is an array of points to meFrameLine structures
     * which hold the physical line contents.
     *
     * Allocate lines in the frame store to hold the video information.
     */
    if((frame->store = meMalloc(sizeof(meFrameLine) * frame->depthMax)) == NULL)
        return NULL ;
    for (flp = frame->store, ii = 0; ii < frame->depthMax; ii++, flp++)
    {
        if ((flp->scheme = meMalloc(frame->widthMax*(sizeof(meUByte)+sizeof(meStyle)))) == NULL)
            return NULL ;
        flp->text = (meUByte *) (flp->scheme+frame->widthMax) ;
        /* Fill with data */
        jj = frame->widthMax ;
        while(--jj >= 0)
        {
            flp->text[jj] = ' ' ;
            flp->scheme[jj] = meSCHEME_NDEFAULT ;
        }
    }
    return frame ;
}