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

@@ -293,11 +293,20 @@ uint32_t xe_memory_heap_alloc(
// will place wherever asked (so long as it doesn't overlap the heap).
if (!base_address) {
// Normal allocation from the managed heap.
uint32_t result;
if (flags & XE_MEMORY_FLAG_PHYSICAL) {
return memory->physical_heap.Alloc(base_address, size, flags, alignment);
result = memory->physical_heap.Alloc(
base_address, size, flags, alignment);
} else {
return memory->virtual_heap.Alloc(base_address, size, flags, alignment);
result = memory->virtual_heap.Alloc(
base_address, size, flags, alignment);
}
if (result) {
if (flags & XE_MEMORY_FLAG_ZERO) {
xe_zero_struct(memory->mapping_base + result, size);
}
}
return result;
} else {
if (base_address >= XE_MEMORY_VIRTUAL_HEAP_LOW &&
base_address < XE_MEMORY_VIRTUAL_HEAP_HIGH) {
@@ -322,6 +331,10 @@ uint32_t xe_memory_heap_alloc(
return 0;
}
if (flags & XE_MEMORY_FLAG_ZERO) {
xe_zero_struct(pv, size);
}
return base_address;
}
}

View File

@@ -43,6 +43,7 @@ uint32_t xe_memory_search_aligned(xe_memory_ref memory, size_t start,
enum {
XE_MEMORY_FLAG_64KB_PAGES = (1 << 1),
XE_MEMORY_FLAG_PHYSICAL = (1 << 2),
XE_MEMORY_FLAG_ZERO = (1 << 3),
};
enum {