void MetaData::typed_data::allocateStorage(size_t size) { mSize = size; if (usesReservoir()) { return; } u.ext_data = malloc(mSize); }
void MetaData::typed_data::freeStorage() { if (!usesReservoir()) { if (u.ext_data) { free(u.ext_data); } } mSize = 0; }
void *MetaData::typed_data::allocateStorage(size_t size) { mSize = size; if (usesReservoir()) { return &u.reservoir; } u.ext_data = malloc(mSize); if (u.ext_data == NULL) { ALOGE("Couldn't allocate %zu bytes for item", size); mSize = 0; } return u.ext_data; }
const void *storage() const { return usesReservoir() ? &u.reservoir : u.ext_data; }