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.
18 lines
518 B
18 lines
518 B
#ifndef MALLOC_SAFE_H
|
|
#define MALLOC_SAFE_H
|
|
|
|
/**
|
|
* Malloc that prints error and restarts the system on failure.
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include "stm32f1xx_hal.h"
|
|
|
|
void *malloc_safe_do(size_t size, const char* file, uint32_t line);
|
|
void *calloc_safe_do(size_t nmemb, size_t size, const char* file, uint32_t line);
|
|
|
|
#define malloc_s(size) malloc_safe_do(size, __FILE__, __LINE__)
|
|
#define calloc_s(nmemb, size) calloc_safe_do(nmemb, size, __FILE__, __LINE__)
|
|
|
|
#endif // MALLOC_SAFE_H
|
|
|