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
33 #define _COMPONENT ACPI_UTILITIES
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 ****************************************************************************/
62 /* Check for an inadvertent size of zero bytes */
65 _REPORT_ERROR (module
, line
, component
,
66 ("Cm_allocate: Attempt to allocate zero bytes\n"));
70 address
= acpi_os_allocate (size
);
72 /* Report allocation error */
74 _REPORT_ERROR (module
, line
, component
,
75 ("Cm_allocate: Could not allocate size %X\n", size
));
85 /*****************************************************************************
87 * FUNCTION: _Cm_callocate
89 * PARAMETERS: Size - Size of the allocation
90 * Component - Component type of caller
91 * Module - Source file name of caller
92 * Line - Line number of caller
94 * RETURN: Address of the allocated memory on success, NULL on failure.
96 * DESCRIPTION: Subsystem equivalent of calloc.
98 ****************************************************************************/
107 void *address
= NULL
;
110 /* Check for an inadvertent size of zero bytes */
113 _REPORT_ERROR (module
, line
, component
,
114 ("Cm_callocate: Attempt to allocate zero bytes\n"));
119 address
= acpi_os_callocate (size
);
122 /* Report allocation error */
124 _REPORT_ERROR (module
, line
, component
,
125 ("Cm_callocate: Could not allocate size %X\n", size
));
134 /*****************************************************************************
138 * PARAMETERS: Address - Address of the memory to deallocate
139 * Component - Component type of caller
140 * Module - Source file name of caller
141 * Line - Line number of caller
145 * DESCRIPTION: Frees the memory at Address
147 ****************************************************************************/
157 if (NULL
== address
) {
158 _REPORT_ERROR (module
, line
, component
,
159 ("_Cm_free: Trying to delete a NULL address\n"));
165 acpi_os_free (address
);