]> git.sesse.net Git - vlc/blob - include/debug.h
* Header cleaning: filled all empty authors fields, added CVS $Id stuff.
[vlc] / include / debug.h
1 /*****************************************************************************
2  * debug.h: vlc debug macros
3  * Stand alone file
4  *****************************************************************************
5  * Copyright (C) 1999, 2000 VideoLAN
6  * $Id: debug.h,v 1.8 2001/03/21 13:42:33 sam Exp $
7  *
8  * Authors: BenoĆ®t Steiner <benny@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Required headers:
27  * - <string.h>
28  * - intf_msg.h
29  *****************************************************************************/
30
31
32 /*****************************************************************************
33  * ASSERT
34  *****************************************************************************
35  * This macro is used to test that a pointer is not nul. It insert the needed
36  * code when the program is compiled with the debug option, but does nothing
37  * in release program.
38  *****************************************************************************/
39 #ifdef DEBUG
40 #define ASSERT(p_Mem)                                                         \
41 if (!(p_Mem))                                                                 \
42     intf_ErrMsg("Void pointer error: "                                        \
43                 "%s line %d (variable %s at address %p)\n",                   \
44                  __FILE__, __LINE__, #p_Mem, &p_Mem);
45
46 #else
47 #define ASSERT(p_Mem)
48
49 #endif
50
51
52 /*****************************************************************************
53  * RZERO
54  *****************************************************************************
55  * This macro is used to initialise a variable to 0. It is very useful when
56  * used with the ASSERT macro. It also only insert the needed code when the
57  * program is compiled with the debug option.
58  *****************************************************************************/
59 #ifdef DEBUG
60 #define RZERO(r_Var)                                                          \
61 bzero(&(r_Var), sizeof((r_Var)));
62
63 #else
64 #define RZERO(r_Var)
65
66 #endif
67
68
69 /*****************************************************************************
70  * PZERO
71  *****************************************************************************
72  * This macro is used to initiase the memory pointed out by a pointer to 0.
73  * It has the same purpose than RZERO, but for pointers.
74  *****************************************************************************/
75 /* It is already defined on BSD */
76 #ifndef PZERO
77 #ifdef DEBUG
78 #define PZERO(p_Mem)                                                          \
79 bzero((p_Mem), sizeof(*(p_Mem)));
80
81 #else
82 #define PZERO(p_Mem)
83
84 #endif
85 #endif
86
87
88 /*****************************************************************************
89  * AZERO
90  *****************************************************************************
91  * This macro is used to initiase an array of variables to 0.
92  * It has the same purpose than RZERO or PZERO, but for array
93  *****************************************************************************/
94 #ifdef DEBUG
95 #define AZERO(p_Array, i_Size)                                                \
96 bzero((p_Array), (i_Size)*sizeof(*(p_Array)));
97
98 #else
99 #define ZERO(p_Array, i_Size)
100
101 #endif