OLD | NEW |
1 /* Copyright (C) 2002-2003 Jean-Marc Valin | 1 /* Copyright (C) 2002-2003 Jean-Marc Valin |
2 Copyright (C) 2007-2009 Xiph.Org Foundation */ | 2 Copyright (C) 2007-2009 Xiph.Org Foundation */ |
3 /** | 3 /** |
4 @file stack_alloc.h | 4 @file stack_alloc.h |
5 @brief Temporary memory allocation on stack | 5 @brief Temporary memory allocation on stack |
6 */ | 6 */ |
7 /* | 7 /* |
8 Redistribution and use in source and binary forms, with or without | 8 Redistribution and use in source and binary forms, with or without |
9 modification, are permitted provided that the following conditions | 9 modification, are permitted provided that the following conditions |
10 are met: | 10 are met: |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 139 |
140 #endif /* ENABLE_VALGRIND */ | 140 #endif /* ENABLE_VALGRIND */ |
141 | 141 |
142 #include "os_support.h" | 142 #include "os_support.h" |
143 #define VARDECL(type, var) type *var | 143 #define VARDECL(type, var) type *var |
144 #define ALLOC(var, size, type) var = PUSH(global_stack, size, type) | 144 #define ALLOC(var, size, type) var = PUSH(global_stack, size, type) |
145 #define SAVE_STACK char *_saved_stack = global_stack; | 145 #define SAVE_STACK char *_saved_stack = global_stack; |
146 | 146 |
147 #endif /* VAR_ARRAYS */ | 147 #endif /* VAR_ARRAYS */ |
148 | 148 |
| 149 |
| 150 #ifdef ENABLE_VALGRIND |
| 151 |
| 152 #include <valgrind/memcheck.h> |
| 153 #define OPUS_CHECK_ARRAY(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*sizeof
(*ptr)) |
| 154 #define OPUS_CHECK_VALUE(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) |
| 155 #define OPUS_CHECK_ARRAY_COND(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*s
izeof(*ptr)) |
| 156 #define OPUS_CHECK_VALUE_COND(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) |
| 157 #define OPUS_PRINT_INT(value) do {fprintf(stderr, #value " = %d at %s:%d\n", val
ue, __FILE__, __LINE__);}while(0) |
| 158 #define OPUS_FPRINTF fprintf |
| 159 |
| 160 #else |
| 161 |
| 162 static inline int _opus_false(void) {return 0;} |
| 163 #define OPUS_CHECK_ARRAY(ptr, len) _opus_false() |
| 164 #define OPUS_CHECK_VALUE(value) _opus_false() |
| 165 #define OPUS_PRINT_INT(value) do{}while(0) |
| 166 #define OPUS_FPRINTF (void) |
| 167 |
| 168 #endif |
| 169 |
| 170 |
149 #endif /* STACK_ALLOC_H */ | 171 #endif /* STACK_ALLOC_H */ |
OLD | NEW |