mirror of
https://github.com/tailix/mrubyvisor.git
synced 2024-11-11 13:50:47 -05:00
Log failed memory allocations
This commit is contained in:
parent
d6b7a4e4ab
commit
5906a4f3ff
2 changed files with 25 additions and 3 deletions
|
@ -2,6 +2,7 @@ MRuby::CrossBuild.new ENV.fetch 'BUILD_NAME' do |conf|
|
|||
conf.toolchain :gcc
|
||||
|
||||
conf.gem core: 'mruby-compiler'
|
||||
conf.gem core: 'mruby-enumerator'
|
||||
|
||||
conf.cc.flags <<
|
||||
'-Wall' <<
|
||||
|
|
27
src/main.c
27
src/main.c
|
@ -40,6 +40,8 @@ void main(
|
|||
const uint32_t multiboot2_info_magic,
|
||||
const struct KernAux_Multiboot2_Info *const multiboot2_info
|
||||
) {
|
||||
kernaux_drivers_console_puts("========================================");
|
||||
|
||||
kernaux_assert_cb = assert;
|
||||
|
||||
ASSERT(multiboot2_info_magic == KERNAUX_MULTIBOOT2_INFO_MAGIC);
|
||||
|
@ -97,22 +99,41 @@ void assert(const char *const file, const int line, const char *const str)
|
|||
|
||||
void *my_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
return KernAux_Malloc_calloc(&allocator.malloc, nmemb, size);
|
||||
void *const result = KernAux_Malloc_calloc(&allocator.malloc, nmemb, size);
|
||||
if (result) {
|
||||
kernaux_drivers_console_printf("calloc(%lu, %lu) = %p\n", nmemb, size, result);
|
||||
} else if (nmemb * size != 0) {
|
||||
kernaux_drivers_console_printf("!calloc(%lu, %lu)\n", nmemb, size);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void my_free(void *ptr)
|
||||
{
|
||||
kernaux_drivers_console_printf("free(%p)\n", ptr);
|
||||
KernAux_Malloc_free(&allocator.malloc, ptr);
|
||||
}
|
||||
|
||||
void *my_malloc(size_t size)
|
||||
{
|
||||
return KernAux_Malloc_malloc(&allocator.malloc, size);
|
||||
void *const result = KernAux_Malloc_malloc(&allocator.malloc, size);
|
||||
if (result) {
|
||||
kernaux_drivers_console_printf("malloc(%lu) = %p\n", size, result);
|
||||
} else if (size != 0) {
|
||||
kernaux_drivers_console_printf("!malloc(%lu)\n", size);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void *my_realloc(void *ptr, size_t size)
|
||||
{
|
||||
return KernAux_Malloc_realloc(&allocator.malloc, ptr, size);
|
||||
void *const result = KernAux_Malloc_realloc(&allocator.malloc, ptr, size);
|
||||
if (result) {
|
||||
kernaux_drivers_console_printf("realloc(%p, %lu) = %p\n", ptr, size, result);
|
||||
} else if (size != 0) {
|
||||
kernaux_drivers_console_printf("!realloc(%p, %lu)\n", ptr, size);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool load_module(
|
||||
|
|
Loading…
Reference in a new issue