static int extract(RBin *bin, int idx) { int narch; struct r_bin_fatmach0_obj_t *fb = bin->bin_obj; struct r_bin_fatmach0_arch_t *arch = r_bin_fatmach0_extract (fb, idx, &narch); if (!arch) return 0; bin->cur.file = strdup (bin->file); bin->cur.buf = arch->b; bin->cur.size = arch->size; bin->cur.offset = arch->offset; free (arch); return narch; }
static RBinXtrData * extract(RBin* bin, int idx) { int narch; RBinXtrData * res = NULL; struct r_bin_fatmach0_obj_t *fb = bin->cur->xtr_obj; struct r_bin_fatmach0_arch_t *arch; arch = r_bin_fatmach0_extract (fb, idx, &narch); if (!arch) return res; res = r_bin_xtrdata_new (NULL, NULL, arch->b, arch->offset, arch->size, narch); r_buf_free (arch->b); free (arch); return res; }
static RBinXtrData * oneshot(RBin *bin, const ut8 *buf, ut64 size, int idx) { void *xtr_obj = r_bin_fatmach0_from_bytes_new (buf, size); struct r_bin_fatmach0_obj_t *fb = xtr_obj; struct r_bin_fatmach0_arch_t *arch; RBinXtrData *res = NULL; int narch; arch = r_bin_fatmach0_extract (fb, idx, &narch); if (!arch) { free_xtr (xtr_obj); return res; } res = r_bin_xtrdata_new (xtr_obj, free_xtr, arch->b, arch->offset, arch->size, narch); r_buf_free (arch->b); free (arch); return res; }