struct btp_sharedlib * btp_sharedlib_new() { struct btp_sharedlib *result = btp_malloc(sizeof(struct btp_sharedlib)); btp_sharedlib_init(result); return result; }
struct btp_thread * btp_thread_new() { struct btp_thread *thread = btp_malloc(sizeof(struct btp_thread)); btp_thread_init(thread); return thread; }
struct btp_backtrace * btp_backtrace_new() { struct btp_backtrace *backtrace = btp_malloc(sizeof(struct btp_backtrace)); btp_backtrace_init(backtrace); return backtrace; }
struct btp_distances * btp_distances_new(int m, int n) { struct btp_distances *distances = btp_malloc(sizeof(struct btp_distances)); /* The number of rows has to be smaller than columns. */ if (m >= n) m = n - 1; assert(m > 0 && n > 1 && m < n); distances->m = m; distances->n = n; distances->distances = btp_malloc(sizeof(*distances->distances) * (get_distance_position(distances, m - 1, n - 1) + 1)); return distances; }
/* When using hash tables, we need to have addresses of the disassembled * program as keys. We could either embed the addresses directly into the * pointer (glib supports that), but that wouldn't allow us to disassemble * 64-bit programs on 32-bit hosts. So we're using this function to allocate * space for the pointer and store it there. * * Note that currently, the code won't work for any other situation than x86-64 * host disassembling x86-64 file anyway. This issue should be resolved when * migrating the code to btparser -- either make it fully portable or take the * restriction into account and don't do any of this pointer nonsense. */ static uintptr_t* addr_alloc(uintptr_t addr) { uintptr_t *a = btp_malloc(sizeof(*a)); *a = addr; return a; }