forked from Green-Sky/tomato
Green Sky
b1fe064484
73d9b845a3 cleanup: Remove old type-ordered event getters. b0840cc02d feat: add ngc events 7df9a51349 refactor: Make event dispatch ordered by receive time. bcb6592af5 test: Add C++ classes wrapping system interfaces. 4cea4f9ca4 fix: Make all the fuzzers work again, and add a test for protodump. c4e209ea1d refactor: Factor out malloc+memcpy into memdup. 87bcc4322d fix: Remove fatal error for non-erroneous case REVERT: 6d634674a9 cleanup: Remove old type-ordered event getters. REVERT: d1d48d1dfc feat: add ngc events REVERT: 994ffecc6b refactor: Make event dispatch ordered by receive time. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 73d9b845a310c3f56d2d6d77ed56b93d84256d6e
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
#ifndef C_TOXCORE_TOXCORE_MEM_TEST_UTIL_H
|
|
#define C_TOXCORE_TOXCORE_MEM_TEST_UTIL_H
|
|
|
|
#include "mem.h"
|
|
#include "test_util.hh"
|
|
|
|
struct Memory_Class {
|
|
static Memory_Funcs const vtable;
|
|
Memory const self;
|
|
|
|
operator Memory const *() const { return &self; }
|
|
|
|
Memory_Class(Memory_Class const &) = default;
|
|
Memory_Class()
|
|
: self{&vtable, this}
|
|
{
|
|
}
|
|
|
|
virtual ~Memory_Class();
|
|
virtual mem_malloc_cb malloc = 0;
|
|
virtual mem_calloc_cb calloc = 0;
|
|
virtual mem_realloc_cb realloc = 0;
|
|
virtual mem_free_cb free = 0;
|
|
};
|
|
|
|
/**
|
|
* Base test Memory class that just forwards to system_memory. Can be
|
|
* subclassed to override individual (or all) functions.
|
|
*/
|
|
class Test_Memory : public Memory_Class {
|
|
const Memory *mem = REQUIRE_NOT_NULL(system_memory());
|
|
|
|
void *malloc(void *obj, uint32_t size) override;
|
|
void *calloc(void *obj, uint32_t nmemb, uint32_t size) override;
|
|
void *realloc(void *obj, void *ptr, uint32_t size) override;
|
|
void free(void *obj, void *ptr) override;
|
|
};
|
|
|
|
#endif // C_TOXCORE_TOXCORE_MEM_TEST_UTIL_H
|