34 #define __ATTRIB __attribute__ ((unused)) static
36 #if !defined(HAVE_POSIX_MEMALIGN)
37 # if defined (HAVE_MEMALIGN)
38 extern int posix_memalign (
void ** __memptr,
size_t __alignment,
size_t __size);
44 void *sm_alloc (
size_t s);
45 void *sm_calloc (
size_t n,
size_t s);
46 void *sm_realloc (
void *p,
size_t s);
47 void *sm_reallocf (
void *p,
size_t s);
48 int sm_memalign (
void **p,
size_t a,
size_t s);
49 void sm_free (
void *p);
51 void * __sm_alloc_dbg (
size_t s,
const char *f,
size_t l);
52 __ATTRIB
void *sm_alloc (
size_t s) {
return __sm_alloc_dbg (s, __FUNCTION__, 0); }
54 void * __sm_calloc_dbg (
size_t n,
size_t s,
const char *f,
size_t l);
55 __ATTRIB
void *sm_calloc (
size_t n,
size_t s) {
return __sm_calloc_dbg (n, s, __FUNCTION__, 0); }
57 void * __sm_realloc_dbg (
void *p,
size_t s,
const char *f,
size_t l);
58 __ATTRIB
void *sm_realloc (
void *p,
size_t s) {
return __sm_realloc_dbg (p, s, __FUNCTION__, 0); }
60 void * __sm_reallocf_dbg (
void *p,
size_t s,
const char *f,
size_t l);
61 __ATTRIB
void *sm_reallocf (
void *p,
size_t s) {
return __sm_reallocf_dbg (p, s, __FUNCTION__, 0); }
63 int __sm_memalign_dbg (
void **p,
size_t a,
size_t s,
const char *f,
size_t l);
64 __ATTRIB
int __sm_memalign (
void **p,
size_t a,
size_t s) {
return __sm_memalign_dbg (p, a, s, __FUNCTION__, 0); }
66 void __sm_free_dbg (
void *p,
const char *f,
size_t l);
67 __ATTRIB
void sm_free (
void *p) { __sm_free_dbg (p, __FUNCTION__, 0); }
69 # define sm_alloc(s) __sm_alloc_dbg (s, __PRETTY_FUNCTION__, __LINE__)
70 # define sm_calloc(n, s) __sm_calloc_dbg (n, s, __PRETTY_FUNCTION__, __LINE__)
71 # define sm_realloc(p, s) __sm_realloc_dbg ((void *)(p), s, __PRETTY_FUNCTION__, __LINE__)
72 # define sm_reallocf(p, s) __sm_reallocf_dbg ((void *)(p), s, __PRETTY_FUNCTION__, __LINE__)
73 # define sm_memalign(p, a, s) __sm_memalign_dbg (p, a, s, __PRETTY_FUNCTION__, __LINE__)
74 # define sm_free(p) __sm_free_dbg ((void *)(p), __PRETTY_FUNCTION__, __LINE__)
77 #define sm_talloc(T) ((T *) sm_alloc(sizeof(T)))
78 #define sm_valloc(v) ((typeof(v) *) sm_alloc(sizeof v))
oscap debug helpers private header