]> git.sesse.net Git - vlc/blob - include/debug.h
Initial revision
[vlc] / include / debug.h
1 /*******************************************************************************
2  * debug.h: vlc debug macros
3  * (c)1999 VideoLAN
4  *******************************************************************************
5  * Stand alone file
6  *******************************************************************************
7  * Required headers:
8  * - <string.h>
9  * - intf_msg.h
10  *******************************************************************************/
11
12
13 /*******************************************************************************
14  * ASSERT
15  *******************************************************************************
16  * This macro is used to test that a pointer is not nul. It insert the needed
17  * code when the program is compiled with the debug option, but does nothing
18  * in release program.
19  *******************************************************************************/
20 #ifdef DEBUG
21 #define ASSERT(p_Mem)                                                           \
22 if (!(p_Mem))                                                                   \
23     intf_ErrMsg("Void pointer error: %s line %d (variable %s at address %p)\n", \
24                  __FILE__, __LINE__, #p_Mem, &p_Mem);
25
26 #else
27 #define ASSERT(p_Mem)
28
29 #endif
30     
31
32 /*******************************************************************************
33  * RZERO
34  *******************************************************************************
35  * This macro is used to initialise a variable to 0. It is very useful when
36  * used with the ASSERT macro. It also only insert the needed code when the
37  * program is compiled with the debug option.
38  *******************************************************************************/
39 #ifdef DEBUG
40 #define RZERO(r_Var)                                                            \
41 bzero(&(r_Var), sizeof((r_Var)));
42
43 #else
44 #define RZERO(r_Var)
45
46 #endif
47
48
49 /*******************************************************************************
50  * PZERO
51  *******************************************************************************
52  * This macro is used to initiase the memory pointed out by a pointer to 0.
53  * It has the same purpose than RZERO, but for pointers.
54  *******************************************************************************/
55 #ifdef DEBUG
56 #define PZERO(p_Mem)                                                            \
57 bzero((p_Mem), sizeof(*(p_Mem)));
58
59 #else
60 #define PZERO(p_Mem)
61
62 #endif
63
64
65 /*******************************************************************************
66  * AZERO
67  *******************************************************************************
68  * This macro is used to initiase an array of variables to 0.
69  * It has the same purpose than RZERO or PZERO, but for array
70  *******************************************************************************/
71 #ifdef DEBUG
72 #define AZERO(p_Array, i_Size)                                                  \
73 bzero((p_Array), (i_Size)*sizeof(*(p_Array)));
74
75 #else
76 #define ZERO(p_Array, i_Size)
77
78 #endif