1 /* mm.c - functions for memory manager */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2002,2005,2007,2008,2009 Free Software Foundation, Inc.
5 *
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <grub/mm.h>
21
22 #include <string.h>
23 #include <stdlib.h>
24
25 GRUB_EXPORT(grub_malloc);
26 GRUB_EXPORT(grub_zalloc);
27 GRUB_EXPORT(grub_free);
28 GRUB_EXPORT(grub_realloc);
29
30 /* Allocate SIZE bytes and return the pointer. */
grub_malloc(grub_size_t size)31 void * grub_malloc (grub_size_t size) {
32 return malloc(size);
33 }
34
grub_zalloc(grub_size_t size)35 void *grub_zalloc (grub_size_t size) {
36 void *ret;
37 ret = malloc(size);
38 memset (ret, 0, size);
39
40 return ret;
41 }
42
grub_free(void * ptr)43 void grub_free (void *ptr) {
44 free(ptr);
45 }
46
grub_realloc(void * ptr,grub_size_t size)47 void * grub_realloc (void *ptr, grub_size_t size) {
48 return realloc(ptr, size);
49 }
50