diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2013-10-17 00:06:42 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2013-10-17 00:06:42 +0000 |
commit | a6028f7332dbf61541a4482e402bf346dad53118 (patch) | |
tree | 3908357b831dbb78c746f73c443b4d7ba5e966f9 /source/components/utilities/utalloc.c | |
parent | 59ce063597ddbda74269a45aba8187dece2fe00a (diff) |
Notes
Diffstat (limited to 'source/components/utilities/utalloc.c')
-rw-r--r-- | source/components/utilities/utalloc.c | 131 |
1 files changed, 39 insertions, 92 deletions
diff --git a/source/components/utilities/utalloc.c b/source/components/utilities/utalloc.c index 2169fe894f04..51eee9719d66 100644 --- a/source/components/utilities/utalloc.c +++ b/source/components/utilities/utalloc.c @@ -51,6 +51,45 @@ ACPI_MODULE_NAME ("utalloc") +#if !defined (USE_NATIVE_ALLOCATE_ZEROED) +/******************************************************************************* + * + * FUNCTION: AcpiOsAllocateZeroed + * + * PARAMETERS: Size - Size of the allocation + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory. + * This is the default implementation. Can be overridden via the + * USE_NATIVE_ALLOCATE_ZEROED flag. + * + ******************************************************************************/ + +void * +AcpiOsAllocateZeroed ( + ACPI_SIZE Size) +{ + void *Allocation; + + + ACPI_FUNCTION_ENTRY (); + + + Allocation = AcpiOsAllocate (Size); + if (Allocation) + { + /* Clear the memory block */ + + ACPI_MEMSET (Allocation, 0, Size); + } + + return (Allocation); +} + +#endif /* !USE_NATIVE_ALLOCATE_ZEROED */ + + /******************************************************************************* * * FUNCTION: AcpiUtCreateCaches @@ -321,95 +360,3 @@ AcpiUtInitializeBuffer ( ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); return (AE_OK); } - - -/******************************************************************************* - * - * FUNCTION: AcpiUtAllocate - * - * 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 malloc. - * - ******************************************************************************/ - -void * -AcpiUtAllocate ( - ACPI_SIZE Size, - UINT32 Component, - const char *Module, - UINT32 Line) -{ - void *Allocation; - - - ACPI_FUNCTION_TRACE_U32 (UtAllocate, Size); - - - /* Check for an inadvertent size of zero bytes */ - - if (!Size) - { - ACPI_WARNING ((Module, Line, - "Attempt to allocate zero bytes, allocating 1 byte")); - Size = 1; - } - - Allocation = AcpiOsAllocate (Size); - if (!Allocation) - { - /* Report allocation error */ - - ACPI_WARNING ((Module, Line, - "Could not allocate size %u", (UINT32) Size)); - - return_PTR (NULL); - } - - return_PTR (Allocation); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtAllocateZeroed - * - * 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. Allocate and zero memory. - * - ******************************************************************************/ - -void * -AcpiUtAllocateZeroed ( - ACPI_SIZE Size, - UINT32 Component, - const char *Module, - UINT32 Line) -{ - void *Allocation; - - - ACPI_FUNCTION_ENTRY (); - - - Allocation = AcpiUtAllocate (Size, Component, Module, Line); - if (Allocation) - { - /* Clear the memory block */ - - ACPI_MEMSET (Allocation, 0, Size); - } - - return (Allocation); -} |