uc-sdk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
malloc.h
Go to the documentation of this file.
1 #ifndef __MALLOC_H__
2 #define __MALLOC_H__
3 
4 #include <reent.h>
5 #include <stddef.h>
6 #include <stdint.h>
7 
8 typedef void * (*malloc_t)(size_t size);
9 typedef void (*free_t)(void * ptr);
10 typedef void * (*realloc_t)(void * ptr, size_t size);
11 
12 void * base_malloc(size_t size);
13 void base_free(void * ptr);
14 void * base_realloc(void * ptr, size_t size);
15 
16 extern malloc_t malloc;
17 extern free_t free;
18 extern realloc_t realloc;
19 
20 static inline void * calloc(size_t nmemb, size_t size) {
21  uint8_t * r = malloc(nmemb * size);
22  size_t i;
23  for (i = 0; i < (size * nmemb); i++)
24  r[i] = 0;
25  return r;
26 }
27 
28 #endif