FreeBSD/sys/contrib/dev/acpica/components/utilities/uttrack.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiUtAllocateZeroedAndTrack
 *
 * PARAMETERS:  Size                - Size of the allocation
 *              Component           - Component type of caller
 *              Module              - Source file name of caller
 *              Line                - Line number of caller
 *
 * RETURN:      Address of the allocated memory on success, NULL on failure.
 *
 * DESCRIPTION: Subsystem equivalent of calloc.
 *
 ******************************************************************************/
AcpiUtAllocateZeroedAndTrack
PARAMETERS:  Size                - Size of the allocation
Component           - Component type of caller
Module              - Source file name of caller
Line                - Line number of caller

Address of the allocated memory on success, NULL on failure.

Subsystem equivalent of calloc.
AcpiUtAllocateZeroedAndTrack PARAMETERS : Size - Size of the allocation Component - Component type of caller Module - Source file name of caller Line - Line number of caller Address of the allocated memory on success NULL on failure . Subsystem equivalent of calloc .
void *
AcpiUtAllocateZeroedAndTrack (
    ACPI_SIZE               Size,
    UINT32                  Component,
    const char              *Module,
    UINT32                  Line)
{
    ACPI_DEBUG_MEM_BLOCK    *Allocation;
    ACPI_STATUS             Status;
    if (!Size)
    {
        ACPI_WARNING ((Module, Line,
            "Attempt to allocate zero bytes, allocating 1 byte"));
        Size = 1;
    }
    Allocation = AcpiOsAllocateZeroed (
        Size + sizeof (ACPI_DEBUG_MEM_HEADER));
    if (!Allocation)
    {
        ACPI_ERROR ((Module, Line,
            "Could not allocate size %u", (UINT32) Size));
        return (NULL);
    }
    Status = AcpiUtTrackAllocation (Allocation, Size,
        ACPI_MEM_CALLOC, Component, Module, Line);
    if (ACPI_FAILURE (Status))
    {
        AcpiOsFree (Allocation);
        return (NULL);
    }
    AcpiGbl_GlobalList->TotalAllocated++;
    AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
    AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
    if (AcpiGbl_GlobalList->CurrentTotalSize >
        AcpiGbl_GlobalList->MaxOccupied)
    {
        AcpiGbl_GlobalList->MaxOccupied =
            AcpiGbl_GlobalList->CurrentTotalSize;
    }
    return ((void *) &Allocation->UserSpace);
}
void * AcpiUtAllocateZeroedAndTrack ( ACPI_SIZE Size , UINT32 Component , const char * Module , UINT32 Line ) { ACPI_DEBUG_MEM_BLOCK * Allocation ; ACPI_STATUS Status ; if ( ! Size ) { ACPI_WARNING ( ( Module , Line , " " ) ) ; Size = 1 ; } Allocation = AcpiOsAllocateZeroed ( Size + sizeof ( ACPI_DEBUG_MEM_HEADER ) ) ; if ( ! Allocation ) { ACPI_ERROR ( ( Module , Line , " " , ( UINT32 ) Size ) ) ; return ( NULL ) ; } Status = AcpiUtTrackAllocation ( Allocation , Size , ACPI_MEM_CALLOC , Component , Module , Line ) ; if ( ACPI_FAILURE ( Status ) ) { AcpiOsFree ( Allocation ) ; return ( NULL ) ; } AcpiGbl_GlobalList -> TotalAllocated ++ ; AcpiGbl_GlobalList -> TotalSize += ( UINT32 ) Size ; AcpiGbl_GlobalList -> CurrentTotalSize += ( UINT32 ) Size ; if ( AcpiGbl_GlobalList -> CurrentTotalSize > AcpiGbl_GlobalList -> MaxOccupied ) { AcpiGbl_GlobalList -> MaxOccupied = AcpiGbl_GlobalList -> CurrentTotalSize ; } return ( ( void * ) & Allocation -> UserSpace ) ; }
FUNCTION:    AcpiUtAllocateZeroedAndTrack
 PARAMETERS:  Size                - Size of the allocation
              Component           - Component type of caller
              Module              - Source file name of caller
              Line                - Line number of caller
FUNCTION : AcpiUtAllocateZeroedAndTrack PARAMETERS : Size - Size of the allocation Component - Component type of caller Module - Source file name of caller Line - Line number of caller
/* Check for an inadvertent size of zero bytes */ /* Report allocation error */