mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
9dffa3ce81
This PR adds the possibility of specifying a memory error callback in the "ram" element of the "config" section. The new configuration attribute is called "memory_error_callback" and its value is the name of a function with the signature "void f(size_t)" that will be called automatically in the following cases: - when malloc, calloc, or realloc (with the 'size' argument greater than 0) return NULL. The callback function will be called with the 'size' argument of the allocation function. - when the allocator encounters an internal error (only when using the 'multiple' allocator). The callback function will be called with the argument set to 0. For now, this feature is only availabsle when using the multiple allocator or the simple allocator, not the built-in libc allocator. Usage example (in the board configuration file): ``` config = { ram = { memory_error_callback = "memory_error" } } ```