libmobi
C library for handling MOBI format ebook documents
debug.h
Go to the documentation of this file.
1 
11 #ifndef libmobi_debug_h
12 #define libmobi_debug_h
13 
14 #include "config.h"
15 #include "mobi.h"
16 
17 #ifndef MOBI_DEBUG
18 #define MOBI_DEBUG 0
19 #endif
20 
21 #if MOBI_DEBUG_ALLOC
28 #define free(x) debug_free(x, __FILE__, __LINE__)
29 #define malloc(x) debug_malloc(x, __FILE__, __LINE__)
30 #define realloc(x, y) debug_realloc(x, y, __FILE__, __LINE__)
31 #define calloc(x, y) debug_calloc(x, y, __FILE__, __LINE__)
33 #endif
34 
35 void debug_free(void *ptr, const char *file, const int line);
36 void *debug_malloc(const size_t size, const char *file, const int line);
37 void *debug_realloc(void *ptr, const size_t size, const char *file, const int line);
38 void *debug_calloc(const size_t num, const size_t size, const char *file, const int line);
39 void print_indx(const MOBIIndx *indx);
40 void print_indx_infl_old(const MOBIIndx *indx);
41 void print_indx_orth_old(const MOBIIndx *indx);
42 
48 #if (MOBI_DEBUG)
49 #define debug_print(fmt, ...) { \
50  fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
51  __LINE__, __func__, __VA_ARGS__); \
52 }
53 #else
54 #define debug_print(fmt, ...)
55 #endif
56 
57 #endif
void debug_free(void *ptr, const char *file, const int line)
Debugging wrapper for free(void *ptr)
Definition: debug.c:24
void print_indx_infl_old(const MOBIIndx *indx)
Dump inflections index (old version)
Definition: debug.c:101
void print_indx_orth_old(const MOBIIndx *indx)
Dump orthographic index (old version)
Definition: debug.c:134
void print_indx(const MOBIIndx *indx)
Dump index values.
Definition: debug.c:80
void * debug_realloc(void *ptr, const size_t size, const char *file, const int line)
Debugging wrapper for realloc(void* ptr, size_t size)
Definition: debug.c:53
void * debug_calloc(const size_t num, const size_t size, const char *file, const int line)
Debugging wrapper for calloc(size_t num, size_t size)
Definition: debug.c:69
void * debug_malloc(const size_t size, const char *file, const int line)
Debugging wrapper for malloc(size_t size)
Definition: debug.c:38
Libmobi main header file.
Parsed INDX record.
Definition: mobi.h:434