1 /******************************************************************************
3 * Module Name: cmalloc - local memory allocation routines
6 *****************************************************************************/
9 * Copyright (C) 2000 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
33 #define _COMPONENT MISCELLANEOUS
34 MODULE_NAME ("cmalloc")
37 /*****************************************************************************
39 * FUNCTION: _Cm_allocate
41 * PARAMETERS: Size - Size of the allocation
42 * Component - Component type of caller
43 * Module - Source file name of caller
44 * Line - Line number of caller
46 * RETURN: Address of the allocated memory on success, NULL on failure.
48 * DESCRIPTION: The subsystem's equivalent of malloc.
50 ****************************************************************************/
64 /* Check for an inadvertent size of zero bytes */
67 _REPORT_ERROR (module
, line
, component
,
68 ("Cm_allocate: Attempt to allocate zero bytes\n"));
72 address
= acpi_os_allocate (size
);
74 /* Report allocation error */
76 _REPORT_ERROR (module
, line
, component
,
77 ("Cm_allocate: Could not allocate size %X\n", size
));
87 /*****************************************************************************
89 * FUNCTION: _Cm_callocate
91 * PARAMETERS: Size - Size of the allocation
92 * Component - Component type of caller
93 * Module - Source file name of caller
94 * Line - Line number of caller
96 * RETURN: Address of the allocated memory on success, NULL on failure.
98 * DESCRIPTION: Subsystem equivalent of calloc.
100 ****************************************************************************/
109 void *address
= NULL
;
110 DEBUG_ONLY_MEMBERS (\
114 /* Check for an inadvertent size of zero bytes */
117 _REPORT_ERROR (module
, line
, component
,
118 ("Cm_callocate: Attempt to allocate zero bytes\n"));
123 address
= acpi_os_callocate (size
);
126 /* Report allocation error */
128 _REPORT_ERROR (module
, line
, component
,
129 ("Cm_callocate: Could not allocate size %X\n", size
));
138 /*****************************************************************************
142 * PARAMETERS: Address - Address of the memory to deallocate
143 * Component - Component type of caller
144 * Module - Source file name of caller
145 * Line - Line number of caller
149 * DESCRIPTION: Frees the memory at Address
151 ****************************************************************************/
161 if (NULL
== address
) {
162 _REPORT_ERROR (module
, line
, component
,
163 ("_Cm_free: Trying to delete a NULL address\n"));
169 acpi_os_free (address
);