aboutsummaryrefslogtreecommitdiff
path: root/src/debug_alloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug_alloc.h')
-rw-r--r--src/debug_alloc.h70
1 files changed, 35 insertions, 35 deletions
diff --git a/src/debug_alloc.h b/src/debug_alloc.h
index 8612d88..37cc686 100644
--- a/src/debug_alloc.h
+++ b/src/debug_alloc.h
@@ -13,59 +13,59 @@
// Debug calls
#ifdef CORTEX_M4
-extern char * __heap_end;
-register char * sp asm ("sp");
+extern char *__heap_end;
+register char *sp asm("sp");
#endif
#if defined(__EMBEDDED__)
-extern void* codec2_malloc(size_t size);
-extern void* codec2_calloc(size_t nmemb, size_t size);
-extern void codec2_free(void* ptr);
+extern void *codec2_malloc(size_t size);
+extern void *codec2_calloc(size_t nmemb, size_t size);
+extern void codec2_free(void *ptr);
#else
#define codec2_malloc(size) (malloc(size))
#define codec2_calloc(nmemb, size) (calloc(nmemb, size))
#define codec2_free(ptr) (free(ptr))
-#endif // defined(__EMBEDDED__)
+#endif // defined(__EMBEDDED__)
- static inline void * DEBUG_MALLOC(const char *func, size_t size) {
- void *ptr = codec2_malloc(size);
- fprintf(stderr, "MALLOC: %s %p %d", func, ptr, (int)size);
+static inline void *DEBUG_MALLOC(const char *func, size_t size) {
+ void *ptr = codec2_malloc(size);
+ fprintf(stderr, "MALLOC: %s %p %d", func, ptr, (int)size);
#ifdef CORTEX_M4
- fprintf(stderr, " : sp %p ", sp);
+ fprintf(stderr, " : sp %p ", sp);
#endif
- if (!ptr) fprintf(stderr, " ** FAILED **");
- fprintf(stderr, "\n");
- return(ptr);
- }
+ if (!ptr) fprintf(stderr, " ** FAILED **");
+ fprintf(stderr, "\n");
+ return (ptr);
+}
- static inline void * DEBUG_CALLOC(const char *func, size_t nmemb, size_t size) {
- void *ptr = codec2_calloc(nmemb, size);
- fprintf(stderr, "CALLOC: %s %p %d %d", func, ptr, (int)nmemb, (int)size);
+static inline void *DEBUG_CALLOC(const char *func, size_t nmemb, size_t size) {
+ void *ptr = codec2_calloc(nmemb, size);
+ fprintf(stderr, "CALLOC: %s %p %d %d", func, ptr, (int)nmemb, (int)size);
#ifdef CORTEX_M4
- fprintf(stderr, " : sp %p ", sp);
+ fprintf(stderr, " : sp %p ", sp);
#endif
- if (!ptr) fprintf(stderr, " ** FAILED **");
- fprintf(stderr, "\n");
- return(ptr);
- }
- static inline void DEBUG_FREE(const char *func, void *ptr) {
- codec2_free(ptr);
- fprintf(stderr, "FREE: %s %p\n", func, ptr);
- }
+ if (!ptr) fprintf(stderr, " ** FAILED **");
+ fprintf(stderr, "\n");
+ return (ptr);
+}
+static inline void DEBUG_FREE(const char *func, void *ptr) {
+ codec2_free(ptr);
+ fprintf(stderr, "FREE: %s %p\n", func, ptr);
+}
#ifdef DEBUG_ALLOC
- #define MALLOC(size) DEBUG_MALLOC(__func__, size)
- #define CALLOC(nmemb, size) DEBUG_CALLOC(__func__, nmemb, size)
- #define FREE(ptr) DEBUG_FREE(__func__, ptr)
-#else //DEBUG_ALLOC
+#define MALLOC(size) DEBUG_MALLOC(__func__, size)
+#define CALLOC(nmemb, size) DEBUG_CALLOC(__func__, nmemb, size)
+#define FREE(ptr) DEBUG_FREE(__func__, ptr)
+#else // DEBUG_ALLOC
// Default to normal calls
- #define MALLOC(size) codec2_malloc(size)
+#define MALLOC(size) codec2_malloc(size)
- #define CALLOC(nmemb, size) codec2_calloc(nmemb, size)
+#define CALLOC(nmemb, size) codec2_calloc(nmemb, size)
- #define FREE(ptr) codec2_free(ptr)
+#define FREE(ptr) codec2_free(ptr)
-#endif //DEBUG_ALLOC
+#endif // DEBUG_ALLOC
-#endif //DEBUG_ALLOC_H
+#endif // DEBUG_ALLOC_H