本文整理汇总了C++中r_list_newf函数的典型用法代码示例。如果您正苦于以下问题:C++ r_list_newf函数的具体用法?C++ r_list_newf怎么用?C++ r_list_newf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_list_newf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: R_NEW0
static void *load_bytes(RBinFile *bf, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb) {
RBinNROObj *bin = R_NEW0 (RBinNROObj);
if (!bin) {
return NULL;
}
ut64 ba = baddr (bf);
bin->methods_list = r_list_newf ((RListFree)free);
bin->imports_list = r_list_newf ((RListFree)free);
bin->classes_list = r_list_newf ((RListFree)free);
ut32 mod0 = readLE32 (bf->buf, NRO_OFFSET_MODMEMOFF);
parseMod (bf, bin, mod0, ba);
return (void *) bin;//(size_t) check_bytes (buf, sz);
}
示例2: load_bytes
static bool load_bytes(RBinFile *bf, void **bin_obj, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb) {
RBinNXOObj *bin = R_NEW0 (RBinNXOObj);
if (!bin) {
return false;
}
ut64 ba = baddr (bf);
bin->methods_list = r_list_newf ((RListFree)free);
bin->imports_list = r_list_newf ((RListFree)free);
bin->classes_list = r_list_newf ((RListFree)free);
ut32 mod0 = readLE32 (bf->buf, NRO_OFFSET_MODMEMOFF);
parseMod (bf->buf, bin, mod0, ba);
*bin_obj = bin;
return true;
}
示例3: r_list_newf
static RList *r_debug_windbg_pids(RDebug *dbg, int pid) {
RListIter *it;
WindProc *p;
RList *ret = r_list_newf (free);
if (!ret) {
return NULL;
}
RList *pids = windbg_list_process(wctx);
if (!pids) {
return ret;
}
r_list_foreach (pids, it, p) {
RDebugPid *newpid = R_NEW0 (RDebugPid);
if (!newpid) {
r_list_free (ret);
return NULL;
}
newpid->path = strdup (p->name);
newpid->pid = p->uniqueid;
newpid->status = 's';
newpid->runnable = true;
r_list_append (ret, newpid);
}
示例4: relocs
static RList * relocs(RBinFile *bf) {
RList *ret = NULL;
RBinReloc *rel = NULL;
const struct r_bin_mz_reloc_t *relocs = NULL;
int i;
if (!bf || !bf->o || !bf->o->bin_obj) {
return NULL;
}
if (!(ret = r_list_newf (free))) {
return NULL;
}
if (!(relocs = r_bin_mz_get_relocs (bf->o->bin_obj))) {
return ret;
}
for (i = 0; !relocs[i].last; i++) {
if (!(rel = R_NEW0 (RBinReloc))) {
free ((void *)relocs);
r_list_free (ret);
return NULL;
}
rel->type = R_BIN_RELOC_16;
rel->vaddr = relocs[i].paddr;
rel->paddr = relocs[i].paddr;
r_list_append (ret, rel);
}
free ((void *)relocs);
return ret;
}
示例5:
static RList *sections(RBinFile *arch) {
RBinWasmObj *bin = arch && arch->o ? arch->o->bin_obj : NULL;
RList *ret = NULL;
RList *secs = NULL;
RBinSection *ptr = NULL;
RBinWasmSection *sec;
if (!(ret = r_list_newf ((RListFree)free))) {
return NULL;
}
if (!(secs = r_bin_wasm_get_sections (bin))) {
r_list_free (ret);
return NULL;
}
RListIter *iter;
r_list_foreach (secs, iter, sec) {
if (!(ptr = R_NEW0 (RBinSection))) {
break;
}
strncpy (ptr->name, (char*)sec->name, R_BIN_SIZEOF_STRINGS);
if (sec->id == R_BIN_WASM_SECTION_DATA || sec->id == R_BIN_WASM_SECTION_MEMORY) {
ptr->is_data = true;
}
ptr->size = sec->payload_len;
ptr->vsize = sec->payload_len;
ptr->vaddr = sec->offset;
ptr->paddr = sec->offset;
ptr->add = true;
// TODO permissions
ptr->srwx = 0;
r_list_append (ret, ptr);
}
return ret;
}
示例6: calloc
static RList *parseSegments(RBuffer *buf, int off, int count) {
ut8 *b = calloc (count, 32);
(void)r_buf_read_at (buf, off, b, count * 32);
int x = off;
int X = 0;
int i;
RList *segments = r_list_newf ((RListFree)r_bin_section_free);
if (!segments) {
return NULL;
}
// eprintf ("Segments: %d\n", count);
for (i = 0; i < count; i++) {
int A = r_read_le32 (b + X + 16);
int B = r_read_le32 (b + X + 16 + 8);
// eprintf ("0x%08x segment 0x%08x 0x%08x %s\n",
// x, A, A + B, b + X);
const char *cname = (const char *)(b + X);
char *name = r_str_ndup (cname, r_str_nlen (cname, 16));
RBinSection *section = newSection (name, A, A + B, true);
free (name);
r_list_append (segments, section);
x += 32;
X += 32;
}
return segments;
}
示例7: spaces_unset_single
static bool spaces_unset_single(RSpaces *sp, const char *name) {
RSpace *space = r_spaces_get (sp, name);
if (!space) {
return false;
}
RSpaceEvent ev = { .data.unset.space = space };
r_event_send (sp->event, R_SPACE_EVENT_UNSET, &ev);
return r_rbtree_delete (&sp->spaces, (void *)name, name_space_cmp, space_node_free);
}
R_API bool r_spaces_unset(RSpaces *sp, const char *name) {
if (name) {
return spaces_unset_single (sp, name);
}
RList *names = r_list_newf ((RListFree)free);
if (!names) {
return false;
}
RBIter it;
RSpace *s;
r_spaces_foreach (sp, it, s) {
r_list_append (names, strdup (s->name));
}
RListIter *lit;
const char *n;
bool res = false;
r_list_foreach (names, lit, n) {
res |= spaces_unset_single (sp, n);
}
示例8: build_str_list_from_iterable
static RList * build_str_list_from_iterable (RList *the_list) {
RList * res = r_list_newf (free);
DsoJsonObj *json_obj;
RListIter *iter;
r_list_foreach (the_list, iter, json_obj) {
char *str = dso_json_obj_to_str (json_obj);
r_list_append (res, str);
}
示例9: r_buf_new
R_API RBuffer *r_buf_new_sparse() {
RBuffer *b = r_buf_new ();
if (!b) {
return NULL;
}
b->sparse = r_list_newf ((RListFree)free);
return b;
}
示例10: xnu_dbg_maps
static RList *r_debug_native_modules_get (RDebug *dbg) {
char *lastname = NULL;
RDebugMap *map;
RListIter *iter, *iter2;
RList *list, *last;
int must_delete;
#if __APPLE__
list = xnu_dbg_maps (dbg, 1);
if (list && !r_list_empty (list)) {
return list;
}
#endif
#if __WINDOWS__
list = w32_dbg_modules (dbg);
if (list && !r_list_empty (list)) {
return list;
}
#endif
list = r_debug_native_map_get (dbg);
if (!list) {
return NULL;
}
last = r_list_newf ((RListFree)r_debug_map_free);
if (!last) {
r_list_free (list);
return NULL;
}
r_list_foreach_safe (list, iter, iter2, map) {
const char *file = map->file;
if (!map->file) {
file = map->file = strdup (map->name);
}
must_delete = 1;
if (file && *file) {
if (file[0] == '/') {
if (lastname) {
if (strcmp (lastname, file)) {
must_delete = 0;
}
} else {
must_delete = 0;
}
}
}
if (must_delete) {
r_list_delete (list, iter);
} else {
r_list_append (last, map);
free (lastname);
lastname = strdup (file);
}
}
list->free = NULL;
free (lastname);
r_list_free (list);
return last;
}
示例11: entries
static RList* entries(RBinFile *arch) {
RBinAddr *ptr = NULL;
RList* ret = r_list_newf (free);
if (!ret) return NULL;
if ((ptr = R_NEW0 (RBinAddr))) {
r_list_append (ret, ptr);
}
return ret;
}
示例12: r_list_newf
R_API RList *r_syscall_list(RSyscall *s) {
RList *list;
if (!s || !s->db) {
return NULL;
}
// show list of syscalls to stdout
list = r_list_newf ((RListFree)r_syscall_item_free);
sdb_foreach (s->db, callback_list, list);
return list;
}
示例13: sections
static RList* sections(RBinFile *arch) {
RList *ret = NULL;
RBinSection *ptr = NULL;
ut64 textsize, datasize, symssize, spszsize, pcszsize;
ut64 entry0 = findEntry (arch->buf, 0);
ut64 entry1 = findEntry (arch->buf, 1);
ut64 entry2 = findEntry (arch->buf, 2);
if (!(ret = r_list_newf (free))) {
return NULL;
}
// add text segment
textsize = r_mem_get_num (arch->buf->buf + 4, 4);
if (!(ptr = R_NEW0 (RBinSection))) {
return ret;
}
if (!entry1) {
entry1 = arch->buf->length;
}
strncpy (ptr->name, "init", R_BIN_SIZEOF_STRINGS);
ptr->size = entry1-entry0;
ptr->vsize = entry1-entry0;
ptr->paddr = entry0 + 4;
ptr->vaddr = entry0;
ptr->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_EXECUTABLE | R_BIN_SCN_MAP; // r-x
r_list_append (ret, ptr);
if (entry1) {
if (entry2) {
if (!(ptr = R_NEW0 (RBinSection)))
return ret;
strncpy (ptr->name, "fini", R_BIN_SIZEOF_STRINGS);
ptr->size = entry2-entry1;
ptr->vsize = entry2-entry1;
ptr->paddr = entry1 + 4;
ptr->vaddr = entry1;
ptr->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_EXECUTABLE | R_BIN_SCN_MAP; // r-x
r_list_append (ret, ptr);
} else {
entry2 = entry1;
}
}
if (entry2) {
if (!(ptr = R_NEW0 (RBinSection)))
return ret;
strncpy (ptr->name, "text", R_BIN_SIZEOF_STRINGS);
ptr->size = arch->buf->length - entry2;
ptr->vsize = arch->buf->length - entry2;
ptr->paddr = entry2 + 4;
ptr->vaddr = entry2;
ptr->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_EXECUTABLE | R_BIN_SCN_MAP; // r-x
r_list_append (ret, ptr);
}
return ret;
}
示例14:
static RList *entries(RBinFile *arch) {
struct r_bin_coff_obj *obj = (struct r_bin_coff_obj*)arch->o->bin_obj;
RList *ret;
RBinAddr *ptr = NULL;
if (!(ret = r_list_newf (free))) {
return NULL;
}
ptr = r_coff_get_entry(obj);
r_list_append(ret, ptr);
return ret;
}
示例15: r_list_newf
static RList *sections(RBinFile *arch) {
char *tmp, *coffname = NULL;
size_t i;
RList *ret = NULL;
RBinSection *ptr = NULL;
struct r_bin_coff_obj *obj = (struct r_bin_coff_obj*)arch->o->bin_obj;
ret = r_list_newf (free);
if (!ret) {
return NULL;
}
if (obj && obj->scn_hdrs) {
for (i = 0; i < obj->hdr.f_nscns; i++) {
free (coffname);
tmp = r_coff_symbol_name (obj, &obj->scn_hdrs[i]);
if (!tmp) {
r_list_free (ret);
return NULL;
}
//IO does not like sections with the same name append idx
//since it will update it
coffname = r_str_newf ("%s-%d", tmp, i);
free (tmp);
ptr = R_NEW0 (RBinSection);
if (!ptr) {
free (coffname);
return ret;
}
strncpy (ptr->name, coffname, R_BIN_SIZEOF_STRINGS);
if (strstr (ptr->name, "data")) {
ptr->is_data = true;
}
ptr->size = obj->scn_hdrs[i].s_size;
ptr->vsize = obj->scn_hdrs[i].s_size;
ptr->paddr = obj->scn_hdrs[i].s_scnptr;
ptr->add = true;
ptr->srwx = R_BIN_SCN_MAP;
if (obj->scn_hdrs[i].s_flags & COFF_SCN_MEM_READ) {
ptr->srwx |= R_BIN_SCN_READABLE;
}
if (obj->scn_hdrs[i].s_flags & COFF_SCN_MEM_WRITE) {
ptr->srwx |= R_BIN_SCN_WRITABLE;
}
if (obj->scn_hdrs[i].s_flags & COFF_SCN_MEM_EXECUTE) {
ptr->srwx |= R_BIN_SCN_EXECUTABLE;
}
r_list_append (ret, ptr);
}
}
free (coffname);
return ret;
}