struct r_bin_mz_obj_t* r_bin_mz_new_buf(const struct r_buf_t *buf) { struct r_bin_mz_obj_t *bin = R_NEW0 (struct r_bin_mz_obj_t); if (!bin) { return NULL; } bin->b = r_buf_new (); bin->size = buf->length; if (!r_buf_set_bytes (bin->b, buf->buf, bin->size)){ return r_bin_mz_free (bin); } return r_bin_mz_init (bin) ? bin : r_bin_mz_free (bin); }
struct r_bin_mz_obj_t* r_bin_mz_new (const char* file) { const ut8 *buf; struct r_bin_mz_obj_t *bin = R_NEW0 (struct r_bin_mz_obj_t); if (!bin) return NULL; bin->file = file; if (!(buf = (ut8*)r_file_slurp (file, &bin->size))) return r_bin_mz_free (bin); bin->b = r_buf_new (); if (!r_buf_set_bytes (bin->b, buf, bin->size)) { free ((void *)buf); return r_bin_mz_free (bin); } free ((void *)buf); if (!r_bin_mz_init (bin)) return r_bin_mz_free (bin); return bin; }
static int destroy(RBinFile *arch) { r_bin_mz_free ((struct r_bin_mz_obj_t*)arch->o->bin_obj); return true; }