EasyGUI
gui_mem.h
1 
6 /*
7  * Copyright (c) 2019 Tilen MAJERLE
8  *
9  * Permission is hereby granted, free of charge, to any person
10  * obtaining a copy of this software and associated documentation
11  * files (the "Software"), to deal in the Software without restriction,
12  * including without limitation the rights to use, copy, modify, merge,
13  * publish, distribute, sublicense, and/or sell copies of the Software,
14  * and to permit persons to whom the Software is furnished to do so,
15  * subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
23  * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  *
29  * This file is part of EasyGUI library.
30  *
31  * Author: Tilen Majerle <tilen@majerle.eu>
32  */
33 #ifndef GUI_HDR_MEM_H
34 #define GUI_HDR_MEM_H
35 
36 /* C++ detection */
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #include "gui_utils.h"
42 
53 typedef struct mem_region_t {
54  void* start_address;
55  size_t size;
56 } mem_region_t;
57 
62 
63 void* gui_mem_alloc(uint32_t size);
64 void* gui_mem_realloc(void* ptr, size_t size);
65 void* gui_mem_calloc(size_t num, size_t size);
66 void gui_mem_free(void* ptr);
67 size_t gui_mem_getfree(void);
68 size_t gui_mem_getfull(void);
69 size_t gui_mem_getminfree(void);
70 
71 uint8_t gui_mem_assignmemory(const gui_mem_region_t* regions, size_t size);
72 
77 /* C++ detection */
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif /* GUI_HDR_MEM_H */
size_t gui_mem_getminfree(void)
Get minimal available number of bytes ever for allocation.
Definition: gui_mem.c:454
void * gui_mem_calloc(size_t num, size_t size)
Allocate memory of specific size and set memory to zero.
Definition: gui_mem.c:404
void * start_address
Definition: gui_mem.h:54
size_t gui_mem_getfull(void)
Get total currently allocated memory in regions.
Definition: gui_mem.c:444
void gui_mem_free(void *ptr)
Free memory.
Definition: gui_mem.c:420
uint8_t gui_mem_assignmemory(const gui_mem_region_t *regions, size_t size)
Assign memory region(s) for allocation functions.
Definition: gui_mem.c:466
mem_region_t gui_mem_region_t
Wrapper for memory region for GUI.
Definition: gui_mem.h:61
size_t size
Definition: gui_mem.h:55
Single memory region descriptor.
Definition: gui_mem.h:53
void * gui_mem_alloc(uint32_t size)
Allocate memory of specific size.
Definition: gui_mem.c:368
void * gui_mem_realloc(void *ptr, size_t size)
Allocate memory of specific size.
Definition: gui_mem.c:388
size_t gui_mem_getfree(void)
Get total free size still available in memory to allocate.
Definition: gui_mem.c:434