#include <signal.h>
#endif /* _WIN32 */
+#include <cmocka_private.h>
#include <cmocka.h>
// Size of guard bytes around dynamically allocated blocks.
const char* const function, const char* const parameter,
const char* const file, const int line, const char* string,
const int count) {
- declare_initialize_value_pointer_pointer(string_pointer, (char*)string);
+ declare_initialize_value_pointer_pointer(string_pointer,
+ discard_const(string));
_expect_check(function, parameter, file, line, check_string,
string_pointer.value, NULL, count);
}
const char* const function, const char* const parameter,
const char* const file, const int line, const char* string,
const int count) {
- declare_initialize_value_pointer_pointer(string_pointer, (char*)string);
+ declare_initialize_value_pointer_pointer(string_pointer,
+ discard_const(string));
_expect_check(function, parameter, file, line, check_not_string,
string_pointer.value, NULL, count);
}
#undef free
void _test_free(void* const ptr, const char* file, const int line) {
unsigned int i;
- char *block = (char*)ptr;
+ char *block = discard_const_p(char, ptr);
+
MallocBlockInfo *block_info;
_assert_true(cast_ptr_to_largest_integral_type(ptr), "ptr", file, line);
block_info = (MallocBlockInfo*)(block - (MALLOC_GUARD_SIZE +
}
list_remove(&block_info->node, NULL, NULL);
- block = (char*)block_info->block;
+ block = discard_const_p(char, block_info->block);
memset(block, MALLOC_FREE_PATTERN, block_info->allocated_size);
free(block);
}
while (node != head) {
MallocBlockInfo * const block_info = (MallocBlockInfo*)node->value;
node = node->next;
- free((char*)block_info + sizeof(*block_info) + MALLOC_GUARD_SIZE);
+ free(discard_const_p(char, block_info) + sizeof(*block_info) + MALLOC_GUARD_SIZE);
}
}