2 * Simple malloc implementation
4 * Copyright (c) 2014 Google, Inc
6 * SPDX-License-Identifier: GPL-2.0+
13 DECLARE_GLOBAL_DATA_PTR;
15 void *malloc_simple(size_t bytes)
20 new_ptr = gd->malloc_ptr + bytes;
21 if (new_ptr > gd->malloc_limit)
23 ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes);
24 gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
28 #ifdef CONFIG_SYS_MALLOC_SIMPLE
29 void *calloc(size_t nmemb, size_t elem_size)
31 size_t size = nmemb * elem_size;
35 memset(ptr, '\0', size);