xref: /optee_os/core/arch/arm/kernel/unwind_private.h (revision 5a913ee74d3c71af2a2860ce8a4e7aeab2916f9b)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2018, Linaro Limited
4  */
5 #include <malloc.h>
6 #include <stddef.h>
7 #include <util.h>
8 
9 static inline void *unw_grow(void *p, size_t *cur_size, size_t new_size)
10 {
11 	if (*cur_size >= new_size)
12 		return p;
13 
14 	size_t rounded_size = ROUNDUP(new_size, 16 * sizeof(vaddr_t));
15 	void *tmp = realloc(p, rounded_size);
16 
17 	if (tmp)
18 		*cur_size = rounded_size;
19 	return tmp;
20 }
21