Dot matrix audio spectrum visualiser based on an stm32f107 STM eval board and several chained MAX2719 drivers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
stm32f107-audio-dotmatrix-v.../User/malloc_safe.c

38 lines
660 B

#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <user_main.h>
#include "malloc_safe.h"
static void reset_when_done(void)
{
//
HAL_NVIC_SystemReset();
}
void *malloc_safe_do(size_t size, const char* file, uint32_t line)
{
void *mem = malloc(size);
if (mem == NULL) {
// malloc failed
user_error_file_line("Malloc failed", file, line);
reset_when_done();
}
return mem;
}
void *calloc_safe_do(size_t nmemb, size_t size, const char* file, uint32_t line)
{
void *mem = calloc(nmemb, size);
if (mem == NULL) {
// malloc failed
user_error_file_line("Calloc failed", file, line);
reset_when_done();
}
return mem;
}