Zero memory on alloc.

This commit is contained in:
Ben Vanik
2013-10-22 21:50:10 -07:00
parent d065ee43e8
commit d9a55a5557
6 changed files with 33 additions and 19 deletions

View File

@@ -133,7 +133,8 @@ X_STATUS XThread::Create() {
// 0x160: last error
// So, at offset 0x100 we have a 4b pointer to offset 200, then have the
// structure.
thread_state_address_ = xe_memory_heap_alloc(memory(), 0, 2048, 0);
thread_state_address_ = xe_memory_heap_alloc(
memory(), 0, 2048, XE_MEMORY_FLAG_ZERO);
if (!thread_state_address_) {
XELOGW("Unable to allocate thread state block");
return X_STATUS_NO_MEMORY;
@@ -147,7 +148,8 @@ X_STATUS XThread::Create() {
// Allocate TLS block.
const xe_xex2_header_t* header = module->xex_header();
uint32_t tls_size = header->tls_info.slot_count * header->tls_info.data_size;
tls_address_ = xe_memory_heap_alloc(memory(), 0, tls_size, 0);
tls_address_ = xe_memory_heap_alloc(
memory(), 0, tls_size, XE_MEMORY_FLAG_ZERO);
if (!tls_address_) {
XELOGW("Unable to allocate thread local storage block");
module->Release();

View File

@@ -533,10 +533,9 @@ int xe_xex2_read_image_uncompressed(const xe_xex2_header_t *header,
// Allocate in-place the XEX memory.
const size_t exe_length = xex_length - header->exe_offset;
size_t uncompressed_size = exe_length;
uint32_t alloc_result =
xe_memory_heap_alloc(memory,
header->exe_address, (uint32_t)uncompressed_size,
0);
uint32_t alloc_result = xe_memory_heap_alloc(
memory, header->exe_address, (uint32_t)uncompressed_size,
XE_MEMORY_FLAG_ZERO);
if (!alloc_result) {
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.",
header->exe_address, uncompressed_size);
@@ -580,10 +579,9 @@ int xe_xex2_read_image_basic_compressed(const xe_xex2_header_t *header,
}
// Allocate in-place the XEX memory.
uint32_t alloc_result =
xe_memory_heap_alloc(memory,
header->exe_address, (uint32_t)uncompressed_size,
0);
uint32_t alloc_result = xe_memory_heap_alloc(
memory, header->exe_address, (uint32_t)uncompressed_size,
XE_MEMORY_FLAG_ZERO);
if (!alloc_result) {
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.",
header->exe_address, uncompressed_size);
@@ -719,10 +717,9 @@ int xe_xex2_read_image_compressed(const xe_xex2_header_t *header,
}
// Allocate in-place the XEX memory.
uint32_t alloc_result =
xe_memory_heap_alloc(memory,
header->exe_address, (uint32_t)uncompressed_size,
0);
uint32_t alloc_result = xe_memory_heap_alloc(
memory, header->exe_address, (uint32_t)uncompressed_size,
XE_MEMORY_FLAG_ZERO);
if (!alloc_result) {
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.",
header->exe_address, uncompressed_size);