MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / MyMemoryCreator

Class MyMemoryCreator

crates/c-api/tests/config.cc:82–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82struct MyMemoryCreator {
83 struct Memory {
84 std::vector<uint8_t> storage;
85
86 uint8_t *get_memory(size_t *byte_size, size_t *byte_capacity) {
87 *byte_size = storage.size();
88 *byte_capacity = storage.capacity();
89 return &storage[0];
90 }
91
92 Result<std::monostate> grow_memory(size_t new_size) {
93 storage.resize(new_size, 0);
94 return std::monostate();
95 }
96 };
97
98 Result<Memory> new_memory(const MemoryType::Ref &ty, size_t minimum,
99 size_t maximum, size_t reserved_size_in_bytes,
100 size_t guard_size_in_bytes) {
101 EXPECT_EQ(guard_size_in_bytes, 0);
102 EXPECT_EQ(reserved_size_in_bytes, 0);
103
104 Memory mem;
105 mem.grow_memory(minimum).unwrap();
106 return mem;
107 }
108};
109
110TEST(Config, MemoryCreator) {
111 Config config;

Callers 1

TESTFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68