Пример #1
0
static STATUS
MExheaddump(
	register ME_HEAD *head,
	i4 (*fmt)())		/* must be a VARARGS function */
{
    MEstatus = OK;

    if (head == NULL)
    {
	MEstatus = ME_00_DUMP;
	(void)(*fmt)("MExheaddump: head is NULL\n");
    }
    else if ( OUT_OF_DATASPACE(head) )
    {
	MEstatus = ME_OUT_OF_RANGE;
	(void)(*fmt)("MEXheaddump: head 0x%p is out of range\n", head );
    }
    else
	(*fmt)( "0x%08x->{ first 0x%08x last 0x%08x }\n",
		head, head->MEfirst, head->MElast );

    return(MEstatus);
}
Пример #2
0
static STATUS
MExnodedump(
	register ME_NODE *node,
	i4 (*fmt)())		/* must be a VARARGS function */
{
    MEstatus = OK;

    if (node == NULL)
    {
	MEstatus = ME_00_DUMP;
	(void)(*fmt)("MExnodedump: node is NULL\n" );
    }	
    else if ( OUT_OF_DATASPACE(node) )
    {
	MEstatus = ME_OUT_OF_RANGE;
	(void)(*fmt)("MExnodedump: node 0x%p out of range\n", node );
    }	
    else
	(void)(*fmt)("0x%08x->{ next 0x%08x  prev 0x%08x  size %d  tag %d }\n",
		node, node->MEnext, node->MEprev, node->MEsize, node->MEtag);

    return( MEstatus );
}
Пример #3
0
STATUS
MEfadd(
	ME_NODE	*block,
	i4 releasep)
{
    register ME_NODE *this;
    register ME_NODE *start;
    register ME_NODE *nextblk;	/* 1st address after end of 'block' */
    STATUS  MEstatus;

    MEstatus = OK;

    if ( block == NULL )
    {
	MEstatus = ME_00_PTR;
    }
    else if ( OUT_OF_DATASPACE(block) )
    {
	MEstatus = ME_OUT_OF_RANGE;
    }
    else
    {

	nextblk = NEXT_NODE(block);

	/*
	** The freelist IS sorted.  We might be able to take
	** advantage of this to speed up this linear search.
	** In practice the freelist is usually much
	** smaller than the allocated list, so it might not
	** really matter (daveb).
	*/

	/* adding inside existing freelist */
	start = (ME_NODE *)&MEfreelist;
	this = MEfreelist.MEfirst;

	while ( this != NULL && this != start && this < nextblk )
	    this = this->MEnext;

	if( this == NULL )
	    MEstatus = ME_CORRUPTED;

	/*
	** this->MEprev points to free node before 'block', the one
	** to free.  this points to the block in the free
	** list following 'block' to free.
	*/
	if ( MEstatus == OK )
	{
	    block->MEaskedfor = 0;
	    (void)QUinsert( (QUEUE *) block, (QUEUE *) this->MEprev );

	    /* Coalesce backwards until this is the start of the queue */
	    this = block;
	    while( this->MEprev != start &&
                 this->MEprev != this && NEXT_NODE(this->MEprev) == this )
	    {
		block = this->MEprev;
		block->MEsize += this->MEsize;
		(void)QUremove( (QUEUE *) this );
		this = block;
	    }

	    /* Coalesce forwards until the queue goes back to the start */
	    while( this->MEnext != start && NEXT_NODE(this) == this->MEnext )
	    {
		this->MEsize += this->MEnext->MEsize;
		(void)QUremove( (QUEUE *) this->MEnext );
	    }
	}
    }
			
    return(MEstatus);
}