1 /******************************************************************************
3 * Module Name: cmalloc - local memory allocation routines
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #define _COMPONENT ACPI_UTILITIES
30 MODULE_NAME ("cmalloc")
33 /*****************************************************************************
35 * FUNCTION: _Cm_allocate
37 * PARAMETERS: Size - Size of the allocation
38 * Component - Component type of caller
39 * Module - Source file name of caller
40 * Line - Line number of caller
42 * RETURN: Address of the allocated memory on success, NULL on failure.
44 * DESCRIPTION: The subsystem's equivalent of malloc.
46 ****************************************************************************/
58 /* Check for an inadvertent size of zero bytes */
61 _REPORT_ERROR (module
, line
, component
,
62 ("Cm_allocate: Attempt to allocate zero bytes\n"));
66 address
= acpi_os_allocate (size
);
68 /* Report allocation error */
70 _REPORT_ERROR (module
, line
, component
,
71 ("Cm_allocate: Could not allocate size %X\n", size
));
81 /*****************************************************************************
83 * FUNCTION: _Cm_callocate
85 * PARAMETERS: Size - Size of the allocation
86 * Component - Component type of caller
87 * Module - Source file name of caller
88 * Line - Line number of caller
90 * RETURN: Address of the allocated memory on success, NULL on failure.
92 * DESCRIPTION: Subsystem equivalent of calloc.
94 ****************************************************************************/
103 void *address
= NULL
;
106 /* Check for an inadvertent size of zero bytes */
109 _REPORT_ERROR (module
, line
, component
,
110 ("Cm_callocate: Attempt to allocate zero bytes\n"));
115 address
= acpi_os_callocate (size
);
118 /* Report allocation error */
120 _REPORT_ERROR (module
, line
, component
,
121 ("Cm_callocate: Could not allocate size %X\n", size
));
130 /*****************************************************************************
134 * PARAMETERS: Address - Address of the memory to deallocate
135 * Component - Component type of caller
136 * Module - Source file name of caller
137 * Line - Line number of caller
141 * DESCRIPTION: Frees the memory at Address
143 ****************************************************************************/
153 if (NULL
== address
) {
154 _REPORT_ERROR (module
, line
, component
,
155 ("_Cm_free: Trying to delete a NULL address\n"));
161 acpi_os_free (address
);