in the event that realloc() fails, this will wipe out the memtypes array and lead to a crash.
The safe pattern is to use a temporary variable and do something like this:

```
uint32_t newsize = memtypes_size * 2;
struct mem_type *newtypes = realloc(memtypes, newsize * sizeof(*memtypes));
if (newtypes) {
    memtypes = newtypes;
    memtypes_size = newsize;
    return true;
}
return false;
```