debug.h 3.75 KB
Newer Older
1
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
2 3
 * debug.h: vlc debug macros
 * Stand alone file
4
 *****************************************************************************
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 * Copyright (C) 1999, 2000 VideoLAN
 *
 * Authors:
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *****************************************************************************/

/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
26 27 28
 * Required headers:
 * - <string.h>
 * - intf_msg.h
29
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
30 31


32
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
33
 * ASSERT
34
 *****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
35 36 37
 * This macro is used to test that a pointer is not nul. It insert the needed
 * code when the program is compiled with the debug option, but does nothing
 * in release program.
38
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
39
#ifdef DEBUG
40 41 42 43
#define ASSERT(p_Mem)                                                         \
if (!(p_Mem))                                                                 \
    intf_ErrMsg("Void pointer error: "                                        \
                "%s line %d (variable %s at address %p)\n",                   \
Michel Kaempf's avatar
Michel Kaempf committed
44 45 46 47 48 49 50
                 __FILE__, __LINE__, #p_Mem, &p_Mem);

#else
#define ASSERT(p_Mem)

#endif

51 52

/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
53
 * RZERO
54
 *****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
55 56 57
 * This macro is used to initialise a variable to 0. It is very useful when
 * used with the ASSERT macro. It also only insert the needed code when the
 * program is compiled with the debug option.
58
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
59
#ifdef DEBUG
60
#define RZERO(r_Var)                                                          \
Michel Kaempf's avatar
Michel Kaempf committed
61 62 63 64 65 66 67 68
bzero(&(r_Var), sizeof((r_Var)));

#else
#define RZERO(r_Var)

#endif


69
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
70
 * PZERO
71
 *****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
72 73
 * This macro is used to initiase the memory pointed out by a pointer to 0.
 * It has the same purpose than RZERO, but for pointers.
74
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
75
#ifdef DEBUG
76
#define PZERO(p_Mem)                                                          \
Michel Kaempf's avatar
Michel Kaempf committed
77 78 79 80 81 82 83 84
bzero((p_Mem), sizeof(*(p_Mem)));

#else
#define PZERO(p_Mem)

#endif


85
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
86
 * AZERO
87
 *****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
88 89
 * This macro is used to initiase an array of variables to 0.
 * It has the same purpose than RZERO or PZERO, but for array
90
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
91
#ifdef DEBUG
92
#define AZERO(p_Array, i_Size)                                                \
Michel Kaempf's avatar
Michel Kaempf committed
93 94 95 96 97 98
bzero((p_Array), (i_Size)*sizeof(*(p_Array)));

#else
#define ZERO(p_Array, i_Size)

#endif