Prusa MINI Firmware overview
|
Go to the source code of this file.
◆ MEM_SIZE_F
◆ mem_size_t
◆ mem_init()
Zero the heap and initialize start, end and lowest-free
◆ mem_trim()
Shrink memory returned by mem_malloc().
- Parameters
-
rmem | pointer to memory allocated by mem_malloc the is to be shrinked |
newsize | required size after shrinking (needs to be smaller than or equal to the previous size) |
- Returns
- for compatibility reasons: is always == rmem, at the moment or NULL if newsize is > old size, in which case rmem is NOT touched or freed!
519 if (newsize >
size) {
523 if (newsize ==
size) {
532 if (mem2->
used == 0) {
542 mem2 = (
struct mem *)(
void *)&
ram[ptr2];
567 mem2 = (
struct mem *)(
void *)&
ram[ptr2];
587 #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
◆ mem_malloc()
Allocate a block of memory with a minimum of 'size' bytes.
- Parameters
-
size | is the minimum size of the requested block in bytes. |
- Returns
- pointer to allocated memory or NULL if no free memory was found.
Note that the returned value will always be aligned (as defined by MEM_ALIGNMENT).
607 #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
608 u8_t local_mem_free_count = 0;
632 #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
635 local_mem_free_count = 0;
642 ptr = ((
struct mem *)(
void *)&
ram[ptr])->
next) {
644 #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
649 if (mem_free_count != 0) {
652 local_mem_free_count = 1;
675 mem2 = (
struct mem *)(
void *)&
ram[ptr2];
698 #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
699 mem_malloc_adjust_lfree:
705 #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
710 if (mem_free_count != 0) {
713 goto mem_malloc_adjust_lfree;
723 LWIP_ASSERT(
"mem_malloc: allocated memory not above ram_end.",
725 LWIP_ASSERT(
"mem_malloc: allocated memory properly aligned.",
733 #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
735 }
while (local_mem_free_count != 0);
◆ mem_calloc()
Contiguously allocates enough space for count objects that are size bytes of memory each and returns a pointer to the allocated memory.
The allocated memory is filled with bytes of value zero.
- Parameters
-
count | number of objects to allocate |
size | size of the objects to allocate |
- Returns
- pointer to allocated memory / NULL pointer if there is an error
773 memset(p, 0, (
size_t)count * (
size_t)
size);
◆ mem_free()
Put a struct mem back on the heap
- Parameters
-
rmem | is the data portion of a struct mem as returned by a previous call to mem_malloc() |
461 #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
#define S16_F
Definition: arch.h:146
#define SYS_ARCH_UNPROTECT(lev)
Definition: sys.h:403
#define LWIP_MEM_ALLOC_PROTECT()
Definition: mem.c:326
int16_t s16_t
Definition: arch.h:122
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
#define LWIP_MEM_ALLOC_DECL_PROTECT()
Definition: mem.c:325
#define LWIP_DBG_LEVEL_SEVERE
Definition: debug.h:59
#define MIN_SIZE_ALIGNED
Definition: mem.c:280
static u8_t * ram
Definition: mem.c:295
u8_t used
Definition: mem.c:270
#define SYS_ARCH_PROTECT(lev)
Definition: sys.h:402
#define LWIP_DBG_TRACE
Definition: debug.h:83
#define MEM_ALIGNMENT
Definition: opt.h:248
#define LWIP_MEM_FREE_UNPROTECT()
Definition: mem.c:323
void sys_mutex_lock(sys_mutex_t *mutex)
Definition: sys_arch.c:355
#define MEM_STATS_DEC_USED(x, y)
Definition: stats.h:398
static struct mem * ram_end
Definition: mem.c:297
#define MEM_DEBUG
Definition: opt.h:2715
mem_size_t prev
Definition: mem.c:268
#define NULL
Definition: usbd_def.h:53
#define LWIP_DBG_LEVEL_SERIOUS
Definition: debug.h:57
mem_size_t next
Definition: mem.c:266
static struct mem * lfree
Definition: mem.c:299
uint8_t u8_t
Definition: arch.h:119
#define LWIP_MEM_FREE_PROTECT()
Definition: mem.c:322
#define LWIP_MEM_ALIGN_SIZE(size)
Definition: arch.h:214
#define LWIP_MEM_ALIGN(addr)
Definition: arch.h:229
err_t sys_mutex_new(sys_mutex_t *mutex)
Definition: sys_arch.c:319
void sys_mutex_unlock(sys_mutex_t *mutex)
Definition: sys_arch.c:362
uintptr_t mem_ptr_t
Definition: arch.h:125
#define SYS_ARCH_DECL_PROTECT(lev)
Definition: sys.h:401
#define LWIP_MEM_ALLOC_UNPROTECT()
Definition: mem.c:327
void * mem_malloc(mem_size_t size)
Definition: mem.c:603
static void plug_holes(struct mem *mem)
Definition: mem.c:344
#define LWIP_MEM_FREE_DECL_PROTECT()
Definition: mem.c:321
#define MEM_STATS_AVAIL(x, y)
Definition: stats.h:395
u16_t mem_size_t
Definition: mem.h:67
#define LWIP_RAM_HEAP_POINTER
Definition: mem.c:291
#define MEM_STATS_INC(x)
Definition: stats.h:396
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:164
#define SIZEOF_STRUCT_MEM
Definition: mem.c:281
#define MEM_SIZE_ALIGNED
Definition: mem.c:282
#define MEM_STATS_INC_USED(x, y)
Definition: stats.h:397
static png_bytep size_t size
Definition: pngwrite.c:2170
static sys_mutex_t mem_mutex
Definition: mem.c:303