mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-04 22:40:25 +02:00
Add a simple memory management wrapper.
* lib/jit_memory.c: Implement a simple memory allocation wrapper to allow overriding calls to malloc/calloc/realloc/free, as well as ensuring all memory containing pointers is zero or points to allocated memory. * include/lightning.h, include/lightning/jit_private.h: Definitions for the memory allocation wrapper. * lib/Makefile.am: Update for new jit_memory.c file. * lib/jit_arm.c, lib/jit_disasm.c, lib/jit_mips.c, lib/jit_note.c, lib/jit_ppc.c, lib/jit_sparc.c, lib/jit_x86.c, lib/lightning.c: Use the new memory allocation wrapper code.
This commit is contained in:
parent
be9068f2ee
commit
c39def9dce
13 changed files with 263 additions and 148 deletions
|
@ -111,7 +111,8 @@ jit_init_debug(void)
|
|||
else
|
||||
dyn_storage = 0;
|
||||
|
||||
disasm_symbols = malloc(sym_storage + dyn_storage);
|
||||
jit_alloc((jit_pointer_t *)&disasm_symbols,
|
||||
(sym_storage + dyn_storage) * sizeof(asymbol *));
|
||||
sym_count = bfd_canonicalize_symtab(disasm_bfd, disasm_symbols);
|
||||
assert(sym_count >= 0);
|
||||
if (dyn_storage) {
|
||||
|
@ -132,10 +133,10 @@ jit_init_debug(void)
|
|||
sym_count,
|
||||
&disasm_synthetic);
|
||||
if (disasm_num_synthetic > 0) {
|
||||
disasm_symbols = realloc(disasm_symbols,
|
||||
sym_storage + dyn_storage +
|
||||
disasm_num_synthetic *
|
||||
sizeof(asymbol *));
|
||||
jit_realloc((jit_pointer_t *)&disasm_symbols,
|
||||
(sym_storage + dyn_storage) * sizeof(asymbol *),
|
||||
(sym_storage + dyn_storage + disasm_num_synthetic) *
|
||||
sizeof(asymbol *));
|
||||
for (offset = 0; offset < disasm_num_synthetic; offset++)
|
||||
disasm_symbols[disasm_num_symbols++] =
|
||||
disasm_synthetic + offset;
|
||||
|
@ -165,9 +166,9 @@ jit_finish_debug(void)
|
|||
{
|
||||
#if DISASSEMBLER
|
||||
if (disasm_synthetic)
|
||||
free(disasm_synthetic);
|
||||
jit_free((jit_pointer_t *)&disasm_synthetic);
|
||||
if (disasm_symbols)
|
||||
free(disasm_symbols);
|
||||
jit_free((jit_pointer_t *)&disasm_symbols);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue