Removing xenia/malloc.*

Using standard memory functions now.
This commit is contained in:
Ben Vanik
2014-08-20 22:22:47 -07:00
parent 609d7c755f
commit cecf83b7b7
36 changed files with 266 additions and 481 deletions

View File

@@ -18,7 +18,7 @@ namespace xe {
namespace kernel {
ObjectTable::ObjectTable()
: table_capacity_(0), table_(NULL), last_free_entry_(0) {}
: table_capacity_(0), table_(nullptr), last_free_entry_(0) {}
ObjectTable::~ObjectTable() {
std::lock_guard<std::mutex> lock(table_mutex_);
@@ -34,7 +34,7 @@ ObjectTable::~ObjectTable() {
table_capacity_ = 0;
last_free_entry_ = 0;
xe_free(table_);
free(table_);
table_ = NULL;
}
@@ -59,12 +59,18 @@ X_STATUS ObjectTable::FindFreeSlot(uint32_t* out_slot) {
// Table out of slots, expand.
uint32_t new_table_capacity = std::max(16 * 1024u, table_capacity_ * 2);
ObjectTableEntry* new_table = (ObjectTableEntry*)xe_recalloc(
table_, table_capacity_ * sizeof(ObjectTableEntry),
new_table_capacity * sizeof(ObjectTableEntry));
size_t new_table_size = new_table_capacity * sizeof(ObjectTableEntry);
size_t old_table_size = table_capacity_ * sizeof(ObjectTableEntry);
ObjectTableEntry* new_table =
(ObjectTableEntry*)realloc(table_, new_table_size);
if (!new_table) {
return X_STATUS_NO_MEMORY;
}
// Zero out new memory.
if (new_table_size > old_table_size) {
memset(reinterpret_cast<uint8_t*>(new_table) + old_table_size, 0,
new_table_size - old_table_size);
}
last_free_entry_ = table_capacity_;
table_capacity_ = new_table_capacity;
table_ = new_table;