comparison dbmalloc.h @ 1571:d4efb7801fcd

Attempt to fix m_free for libtomcrypt/libtommath
author Matt Johnston <matt@ucc.asn.au>
date Fri, 02 Mar 2018 00:02:06 +0800
parents c42e8ff42bd1
children 8dc43b30c6bf
comparison
equal deleted inserted replaced
1570:67cb1983500b 1571:d4efb7801fcd
1 #ifndef DBMALLOC_H_ 1 #ifndef DBMALLOC_H_
2 #define DBMALLOC_H_ 2 #define DBMALLOC_H_
3 3
4 #include "includes.h" 4 #include "stdint.h"
5 #include "stdlib.h"
6 #include "options.h"
5 7
6 void * m_malloc(size_t size); 8 void * m_malloc(size_t size);
7 void * m_calloc(size_t nmemb, size_t size); 9 void * m_calloc(size_t nmemb, size_t size);
8 void * m_strdup(const char * str); 10 void * m_strdup(const char * str);
9 void * m_realloc(void* ptr, size_t size); 11 void * m_realloc(void* ptr, size_t size);
10 12
11 #if DROPBEAR_TRACKING_MALLOC 13 #if DROPBEAR_TRACKING_MALLOC
12 void m_free_direct(void* ptr); 14 void m_free_direct(void* ptr);
13 #define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
14 void m_malloc_set_epoch(unsigned int epoch); 15 void m_malloc_set_epoch(unsigned int epoch);
15 void m_malloc_free_epoch(unsigned int epoch, int dofree); 16 void m_malloc_free_epoch(unsigned int epoch, int dofree);
16 17
17 #else 18 #else
18 /* plain wrapper */ 19 /* plain wrapper */
19 20 #define m_free_direct free
20 #define m_free(X) do {free(X); (X) = NULL;} while (0)
21 21
22 #endif 22 #endif
23 23
24 #define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
25
24 26
25 #endif /* DBMALLOC_H_ */ 27 #endif /* DBMALLOC_H_ */