Changeset View
Changeset View
Standalone View
Standalone View
src/test/raii_event_tests.cpp
Show All 19 Lines | |||||
#include <vector> | #include <vector> | ||||
static std::map<void *, short> tags; | static std::map<void *, short> tags; | ||||
static std::map<void *, uint16_t> orders; | static std::map<void *, uint16_t> orders; | ||||
static uint16_t tagSequence = 0; | static uint16_t tagSequence = 0; | ||||
static void *tag_malloc(size_t sz) { | static void *tag_malloc(size_t sz) { | ||||
void *mem = malloc(sz); | void *mem = malloc(sz); | ||||
if (!mem) return mem; | if (!mem) { | ||||
return mem; | |||||
} | |||||
tags[mem]++; | tags[mem]++; | ||||
orders[mem] = tagSequence++; | orders[mem] = tagSequence++; | ||||
return mem; | return mem; | ||||
} | } | ||||
static void tag_free(void *mem) { | static void tag_free(void *mem) { | ||||
tags[mem]--; | tags[mem]--; | ||||
orders[mem] = tagSequence++; | orders[mem] = tagSequence++; | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |