mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-29 22:23:06 +00:00
f218c41d83
* TODO FL-3497: impossible to fix with current memory allocator * TODO FL-3497: removed, requires radically different settings approach * TODO FL-3514: removed, yes we should * TODO FL-3498: implemented, guarding view port access with mutex. * TODO FL-3515: removed, questionable but ok * TODO FL-3510: removed, comment added * TODO FL-3500: refactored, store pin numbers in GpioPinRecord, fix gpio app crash caused by incorrect gpio_pins traversal. * Format Sources * TODO FL-3505: removed, mutex alone is not going to fix issue with WPAN architecture * TODO FL-3506: removed, change ownership by copy is good * TODO FL-3519: documentation and link to source added * Lib: remove unneded total sum from comment in bq27220 --------- Co-authored-by: hedger <hedger@users.noreply.github.com>
38 lines
878 B
C
38 lines
878 B
C
#include "../minunit.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
|
|
void test_furi_memmgr() {
|
|
void* ptr;
|
|
|
|
// allocate memory case
|
|
ptr = malloc(100);
|
|
mu_check(ptr != NULL);
|
|
// test that memory is zero-initialized after allocation
|
|
for(int i = 0; i < 100; i++) {
|
|
mu_assert_int_eq(0, ((uint8_t*)ptr)[i]);
|
|
}
|
|
free(ptr);
|
|
|
|
// reallocate memory case
|
|
ptr = malloc(100);
|
|
memset(ptr, 66, 100);
|
|
ptr = realloc(ptr, 200);
|
|
mu_check(ptr != NULL);
|
|
|
|
// test that memory is really reallocated
|
|
for(int i = 0; i < 100; i++) {
|
|
mu_assert_int_eq(66, ((uint8_t*)ptr)[i]);
|
|
}
|
|
|
|
free(ptr);
|
|
|
|
// allocate and zero-initialize array (calloc)
|
|
ptr = calloc(100, 2);
|
|
mu_check(ptr != NULL);
|
|
for(int i = 0; i < 100 * 2; i++) {
|
|
mu_assert_int_eq(0, ((uint8_t*)ptr)[i]);
|
|
}
|
|
free(ptr);
|
|
}
|