mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibC: Improve malloc() mmap names somewhat.
This commit is contained in:
parent
4291e96991
commit
2dc72bb297
1 changed files with 7 additions and 4 deletions
|
@ -123,9 +123,12 @@ void* malloc(size_t size)
|
||||||
|
|
||||||
if (!allocator) {
|
if (!allocator) {
|
||||||
size_t real_size = sizeof(BigAllocationBlock) + size;
|
size_t real_size = sizeof(BigAllocationBlock) + size;
|
||||||
void* page_ptr = os_alloc(real_size);
|
auto* block = (BigAllocationBlock*)os_alloc(real_size);
|
||||||
BigAllocationBlock* bigalloc_header = new (page_ptr) BigAllocationBlock(real_size);
|
char buffer[64];
|
||||||
return &bigalloc_header->m_slot[0];
|
snprintf(buffer, sizeof(buffer), "malloc: BigAllocationBlock(%u)", good_size);
|
||||||
|
set_mmap_name(block, PAGE_SIZE, buffer);
|
||||||
|
new (block) BigAllocationBlock(real_size);
|
||||||
|
return &block->m_slot[0];
|
||||||
}
|
}
|
||||||
assert(allocator);
|
assert(allocator);
|
||||||
|
|
||||||
|
@ -138,7 +141,7 @@ void* malloc(size_t size)
|
||||||
if (!block) {
|
if (!block) {
|
||||||
block = (ChunkedBlock*)os_alloc(PAGE_SIZE);
|
block = (ChunkedBlock*)os_alloc(PAGE_SIZE);
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
snprintf(buffer, sizeof(buffer), "malloc() page (%u)", good_size);
|
snprintf(buffer, sizeof(buffer), "malloc: ChunkedBlock(%u)", good_size);
|
||||||
set_mmap_name(block, PAGE_SIZE, buffer);
|
set_mmap_name(block, PAGE_SIZE, buffer);
|
||||||
new (block) ChunkedBlock(good_size);
|
new (block) ChunkedBlock(good_size);
|
||||||
allocator->append(block);
|
allocator->append(block);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue