Beispiel #1
0
FudgeStatus FudgeMsg_release ( FudgeMsg message )
{
    if ( ! message )
        return FUDGE_NULL_POINTER;

    if ( ! FudgeRefCount_decrementAndReturn ( message->refcount ) )
    {
        /* Last reference has been released - destroy the message and all of its fields */
        FudgeStatus status;
        FieldListNode * node;

        if ( ( status = FudgeRefCount_destroy ( message->refcount ) ) != FUDGE_OK )
            return status;

        while ( message->fieldhead )
        {
            node = message->fieldhead;
            message->fieldhead = node->next;
            FieldListNode_destroy ( node );
        }

        free ( message );
    }
    return FUDGE_OK;
}
Beispiel #2
0
FudgeStatus FudgeMsgEnvelope_release ( FudgeMsgEnvelope envelope )
{
    if ( ! envelope )
        return FUDGE_NULL_POINTER;

    if ( ! FudgeRefCount_decrementAndReturn ( envelope->refcount ) )
    {
        /* Last reference has been released - release the message and destroy the envelope */
        FudgeStatus status;

        if ( ( status = FudgeMsg_release ( envelope->message ) ) != FUDGE_OK )
            return status;

        if ( ( status = FudgeRefCount_destroy ( envelope->refcount ) ) != FUDGE_OK )
            return status;

        FUDGEMEMORY_FREE( envelope );
    }
    return FUDGE_OK;
}