Skip to content

Commit

Permalink
LibC: Make the address argument of malloc_size a pointer to const
Browse files Browse the repository at this point in the history
We don't mutate the pointed-to memory, so let's be const correct.

Fixes building the `mimalloc` library that's optionally used by the mold
linker (note that it isn't enabled yet as I haven't tested it).
  • Loading branch information
BertalanD authored and awesomekling committed Jan 12, 2022
1 parent 9e8c4bb commit c7423dc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Userland/Libraries/LibC/malloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ void* calloc(size_t count, size_t size)
return ptr;
}

size_t malloc_size(void* ptr)
size_t malloc_size(void const* ptr)
{
MemoryAuditingSuppressor suppressor;
if (!ptr)
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibC/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ __attribute__((noreturn)) void _abort(void);

__attribute__((malloc)) __attribute__((alloc_size(1))) void* malloc(size_t);
__attribute__((malloc)) __attribute__((alloc_size(1, 2))) void* calloc(size_t nmemb, size_t);
size_t malloc_size(void*);
size_t malloc_size(void const*);
size_t malloc_good_size(size_t);
void serenity_dump_malloc_stats(void);
void free(void*);
Expand Down

0 comments on commit c7423dc

Please sign in to comment.