1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-10-14 06:20:25 +02:00
Files
flashrom/tests/unittest_env.h
Anastasia Klimchuk 7d6a243779 tests: Use SPDX in headers
Change-Id: I3a8a8e59cbed871e0ecf953e547de56c0656e112
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/89361
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Antonio Vázquez Blanco <antoniovazquezblanco@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-10-11 06:02:44 +00:00

41 lines
1.2 KiB
C

/*
* This file is part of the flashrom project.
*
* SPDX-License-Identifier: GPL-2.0-only
* SPDX-FileCopyrightText: 2021 Google LLC
*/
/*
* This header is included in all files when they are built for unit test
* environment, for all the files to be covered by dynamic memory allocation
* checks (checks for memory leaks, buffer overflows and underflows).
*
* See flashrom_test_dep in meson.build for more details.
*
* https://api.cmocka.org/group__cmocka__alloc.html
*/
extern void* _test_malloc(const size_t size, const char* file, const int line);
extern void* _test_realloc(void *ptr, const size_t size, const char* file, const int line);
extern void* _test_calloc(const size_t number_of_elements, const size_t size,
const char* file, const int line);
extern void _test_free(void* const ptr, const char* file, const int line);
#ifdef malloc
#undef malloc
#endif
#ifdef calloc
#undef calloc
#endif
#ifdef realloc
#undef realloc
#endif
#ifdef free
#undef free
#endif
#define malloc(size) _test_malloc(size, __FILE__, __LINE__)
#define realloc(ptr, size) _test_realloc(ptr, size, __FILE__, __LINE__)
#define calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__)
#define free(ptr) _test_free(ptr, __FILE__, __LINE__)