FreeBSD/sys/contrib/dev/acpica/components/utilities/utcache.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiOsReleaseObject
 *
 * PARAMETERS:  Cache       - Handle to cache object
 *              Object      - The object to be released
 *
 * RETURN:      None
 *
 * DESCRIPTION: Release an object to the specified cache. If cache is full,
 *              the object is deleted.
 *
 ******************************************************************************/
AcpiOsReleaseObject
PARAMETERS:  Cache       - Handle to cache object
Object      - The object to be released

None

Release an object to the specified cache. If cache is full,
the object is deleted.
AcpiOsReleaseObject PARAMETERS : Cache - Handle to cache object Object - The object to be released None Release an object to the specified cache . If cache is full the object is deleted .
ACPI_STATUS
AcpiOsReleaseObject (
    ACPI_MEMORY_LIST        *Cache,
    void                    *Object)
{
    ACPI_STATUS             Status;
    ACPI_FUNCTION_ENTRY ();
    if (!Cache || !Object)
    {
        return (AE_BAD_PARAMETER);
    }
    if (Cache->CurrentDepth >= Cache->MaxDepth)
    {
        ACPI_FREE (Object);
        ACPI_MEM_TRACKING (Cache->TotalFreed++);
    }
    else
    {
        Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
        if (ACPI_FAILURE (Status))
        {
            return (Status);
        }
        memset (Object, 0xCA, Cache->ObjectSize);
        ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED);
        ACPI_SET_DESCRIPTOR_PTR (Object, Cache->ListHead);
        Cache->ListHead = Object;
        Cache->CurrentDepth++;
        (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
    }
    return (AE_OK);
}
ACPI_STATUS AcpiOsReleaseObject ( ACPI_MEMORY_LIST * Cache , void * Object ) { ACPI_STATUS Status ; ACPI_FUNCTION_ENTRY ( ) ; if ( ! Cache || ! Object ) { return ( AE_BAD_PARAMETER ) ; } if ( Cache -> CurrentDepth >= Cache -> MaxDepth ) { ACPI_FREE ( Object ) ; ACPI_MEM_TRACKING ( Cache -> TotalFreed ++ ) ; } else { Status = AcpiUtAcquireMutex ( ACPI_MTX_CACHES ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } memset ( Object , 0xCA , Cache -> ObjectSize ) ; ACPI_SET_DESCRIPTOR_TYPE ( Object , ACPI_DESC_TYPE_CACHED ) ; ACPI_SET_DESCRIPTOR_PTR ( Object , Cache -> ListHead ) ; Cache -> ListHead = Object ; Cache -> CurrentDepth ++ ; ( void ) AcpiUtReleaseMutex ( ACPI_MTX_CACHES ) ; } return ( AE_OK ) ; }
FUNCTION:    AcpiOsReleaseObject
 PARAMETERS:  Cache       - Handle to cache object
              Object      - The object to be released
FUNCTION : AcpiOsReleaseObject PARAMETERS : Cache - Handle to cache object Object - The object to be released
/* If cache is full, just free this object */ /* Otherwise put this object back into the cache */ /* Mark the object as cached */ /* Put the object at the head of the cache list */