* Rename MALLOC_STRUCT into R_NEW and deprecate it.

This commit is contained in:
Nibble 2010-03-12 13:35:10 +01:00
parent b9ec80b4b2
commit 9af6794cec
44 changed files with 78 additions and 80 deletions

View File

@ -20,7 +20,7 @@ static RAnalysisVarType anal_default_vartypes[] =
{ NULL, NULL, 0 }};
R_API RAnalysis *r_anal_new() {
return r_anal_init (MALLOC_STRUCT (RAnalysis));
return r_anal_init (R_NEW (RAnalysis));
}
R_API RAnalysis *r_anal_free(RAnalysis *a) {

View File

@ -7,7 +7,7 @@
#include <r_list.h>
R_API RAnalysisAop *r_anal_aop_new() {
return r_anal_aop_init (MALLOC_STRUCT (RAnalysisAop));
return r_anal_aop_init (R_NEW (RAnalysisAop));
}
R_API RList *r_anal_aop_list_new() {

View File

@ -7,7 +7,7 @@
#include <r_list.h>
R_API RAnalysisBB *r_anal_bb_new() {
return r_anal_bb_init (MALLOC_STRUCT (RAnalysisBB));
return r_anal_bb_init (R_NEW (RAnalysisBB));
}
R_API RList *r_anal_bb_list_new() {

View File

@ -11,7 +11,7 @@ R_API void r_anal_ctx_init(struct r_anal_ctx_t *ctx)
R_API struct r_anal_ctx_t *r_anal_ctx_new(struct r_anal_t *anal)
{
struct r_anal_ctx_t *ctx = MALLOC_STRUCT(struct r_anal_ctx_t);
struct r_anal_ctx_t *ctx = R_NEW(struct r_anal_ctx_t);
r_anal_ctx_init(ctx);
ctx->anal = anal;
return ctx;

View File

@ -7,7 +7,7 @@
#include <r_list.h>
R_API RAnalysisFcn *r_anal_fcn_new() {
return r_anal_fcn_init (MALLOC_STRUCT (RAnalysisFcn));
return r_anal_fcn_init (R_NEW (RAnalysisFcn));
}
R_API RList *r_anal_fcn_list_new() {

View File

@ -7,7 +7,7 @@
#include <r_list.h>
R_API RAnalysisRef *r_anal_ref_new() {
return r_anal_ref_init (MALLOC_STRUCT (RAnalysisRef));
return r_anal_ref_init (R_NEW (RAnalysisRef));
}
R_API RList *r_anal_ref_list_new() {

View File

@ -8,7 +8,7 @@
R_API struct r_anal_refline_t *r_anal_reflines_get(struct r_anal_t *anal,
ut64 addr, ut8 *buf, ut64 len, int nlines, int linesout)
{
struct r_anal_refline_t *list = MALLOC_STRUCT (struct r_anal_refline_t);
struct r_anal_refline_t *list = R_NEW (struct r_anal_refline_t);
struct r_anal_refline_t *list2;
struct r_anal_aop_t aop;
ut8 *ptr = buf;
@ -48,7 +48,7 @@ R_API struct r_anal_refline_t *r_anal_reflines_get(struct r_anal_t *anal,
goto __next;
if (aop.jump == 0)
goto __next;
list2 = MALLOC_STRUCT(struct r_anal_refline_t);
list2 = R_NEW(struct r_anal_refline_t);
list2->from = addr;
list2->to = aop.jump;
list2->index = index++;

View File

@ -7,15 +7,15 @@
#include <r_list.h>
R_API RAnalysisVar *r_anal_var_new() {
return r_anal_var_init (MALLOC_STRUCT (RAnalysisVar));
return r_anal_var_init (R_NEW (RAnalysisVar));
}
R_API RAnalysisVarType *r_anal_var_type_new() {
return r_anal_var_type_init (MALLOC_STRUCT (RAnalysisVarType));
return r_anal_var_type_init (R_NEW (RAnalysisVarType));
}
R_API RAnalysisVarAccess *r_anal_var_access_new() {
return r_anal_var_access_init (MALLOC_STRUCT (RAnalysisVarAccess));
return r_anal_var_access_init (R_NEW (RAnalysisVarAccess));
}
R_API RList *r_anal_var_list_new() {

View File

@ -42,7 +42,7 @@ static RList* get_strings(RBin *bin, int min) {
} else {
/* check if the length fits on our request */
if (matches >= min) {
if (!(ptr = MALLOC_STRUCT (RBinString))) {
if (!(ptr = R_NEW (RBinString))) {
fprintf(stderr, "Error allocating string\n");
break;
}

View File

@ -34,7 +34,7 @@ static RList* entries(RBin *bin)
if (!(ret = r_list_new ()))
return NULL;
ret->free = free;
if (!(ptr = MALLOC_STRUCT (RBinEntry)))
if (!(ptr = R_NEW (RBinEntry)))
return ret;
memset (ptr, '\0', sizeof (RBinEntry));
ptr->offset = ptr->rva = Elf_(r_bin_elf_get_entry_offset) (bin->bin_obj);
@ -55,7 +55,7 @@ static RList* sections(RBin *bin)
if (!(section = Elf_(r_bin_elf_get_sections) (bin->bin_obj)))
return ret;
for (i = 0; !section[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinSection)))
if (!(ptr = R_NEW (RBinSection)))
break;
strncpy (ptr->name, (char*)section[i].name, R_BIN_SIZEOF_STRINGS);
ptr->size = section[i].size;
@ -88,7 +88,7 @@ static RList* symbols(RBin *bin)
if (!(symbol = Elf_(r_bin_elf_get_symbols) (bin->bin_obj, R_BIN_ELF_SYMBOLS)))
return ret;
for (i = 0; !symbol[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinSymbol)))
if (!(ptr = R_NEW (RBinSymbol)))
break;
strncpy (ptr->name, symbol[i].name, R_BIN_SIZEOF_STRINGS);
strncpy (ptr->forwarder, "NONE", R_BIN_SIZEOF_STRINGS);
@ -117,7 +117,7 @@ static RList* imports(RBin *bin)
if (!(import = Elf_(r_bin_elf_get_symbols) (bin->bin_obj, R_BIN_ELF_IMPORTS)))
return ret;
for (i = 0; !import[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinImport)))
if (!(ptr = R_NEW (RBinImport)))
break;
strncpy(ptr->name, import[i].name, R_BIN_SIZEOF_STRINGS);
strncpy(ptr->bind, import[i].bind, R_BIN_SIZEOF_STRINGS);
@ -157,7 +157,7 @@ static RBinInfo* info(RBin *bin)
struct r_bin_info_t *ret = NULL;
char *str;
if(!(ret = MALLOC_STRUCT (RBinInfo)))
if(!(ret = R_NEW (RBinInfo)))
return NULL;
memset(ret, '\0', sizeof (RBinInfo));
strncpy (ret->file, bin->file, R_BIN_SIZEOF_STRINGS);
@ -212,7 +212,7 @@ static RList* fields(RBin *bin)
if (!(field = Elf_(r_bin_elf_get_fields) (bin->bin_obj)))
return ret;
for (i = 0; !field[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinField)))
if (!(ptr = R_NEW (RBinField)))
break;
strncpy (ptr->name, field[i].name, R_BIN_SIZEOF_STRINGS);
ptr->rva = field[i].offset;

View File

@ -29,7 +29,7 @@ static RList* entries(RBin *bin)
if (!(ret = r_list_new ()))
return NULL;
ret->free = free;
if (!(ptr = MALLOC_STRUCT (RBinEntry)))
if (!(ptr = R_NEW (RBinEntry)))
return ret;
memset (ptr, '\0', sizeof (RBinEntry));
ptr->offset = ptr->rva = r_bin_java_get_entrypoint (bin->bin_obj);
@ -55,7 +55,7 @@ static RList* symbols(RBin *bin)
if (!(symbols = r_bin_java_get_symbols ((struct r_bin_java_obj_t*)bin->bin_obj)))
return ret;
for (i = 0; !symbols[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinSymbol)))
if (!(ptr = R_NEW (RBinSymbol)))
break;
strncpy (ptr->name, symbols[i].name, R_BIN_SIZEOF_STRINGS);
strncpy (ptr->forwarder, "NONE", R_BIN_SIZEOF_STRINGS);
@ -83,7 +83,7 @@ static RList* strings(RBin *bin)
if (!(strings = r_bin_java_get_strings((struct r_bin_java_obj_t*)bin->bin_obj)))
return ret;
for (i = 0; !strings[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinString)))
if (!(ptr = R_NEW (RBinString)))
break;
strncpy (ptr->string, strings[i].str, R_BIN_SIZEOF_STRINGS);
ptr->rva = ptr->offset = strings[i].offset;
@ -99,7 +99,7 @@ static RBinInfo* info(RBin *bin)
RBinInfo *ret = NULL;
char *version;
if(!(ret = MALLOC_STRUCT (RBinInfo)))
if(!(ret = R_NEW (RBinInfo)))
return NULL;
memset(ret, '\0', sizeof (RBinInfo));
strncpy (ret->file, bin->file, R_BIN_SIZEOF_STRINGS);

View File

@ -37,7 +37,7 @@ static RList* entries(RBin *bin)
ret->free = free;
if (!(entry = MACH0_(r_bin_mach0_get_entrypoint) (bin->bin_obj)))
return ret;
if ((ptr = MALLOC_STRUCT (RBinEntry))) {
if ((ptr = R_NEW (RBinEntry))) {
memset (ptr, '\0', sizeof (RBinEntry));
ptr->offset = entry->offset;
ptr->rva = entry->addr;
@ -60,7 +60,7 @@ static RList* sections(RBin *bin)
if (!(sections = MACH0_(r_bin_mach0_get_sections) (bin->bin_obj)))
return ret;
for (i = 0; !sections[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinSection)))
if (!(ptr = R_NEW (RBinSection)))
break;
strncpy (ptr->name, (char*)sections[i].name, R_BIN_SIZEOF_STRINGS);
ptr->size = sections[i].size;
@ -87,7 +87,7 @@ static RList* symbols(RBin *bin)
if (!(symbols = MACH0_(r_bin_mach0_get_symbols) (bin->bin_obj)))
return ret;
for (i = 0; !symbols[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinSymbol)))
if (!(ptr = R_NEW (RBinSymbol)))
break;
strncpy (ptr->name, (char*)symbols[i].name, R_BIN_SIZEOF_STRINGS);
strncpy (ptr->forwarder, "NONE", R_BIN_SIZEOF_STRINGS);
@ -116,7 +116,7 @@ static RList* imports(RBin *bin)
if (!(imports = MACH0_(r_bin_mach0_get_imports) (bin->bin_obj)))
return ret;
for (i = 0; !imports[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinImport)))
if (!(ptr = R_NEW (RBinImport)))
break;
strncpy (ptr->name, (char*)imports[i].name, R_BIN_SIZEOF_STRINGS);
strncpy (ptr->bind, "NONE", R_BIN_SIZEOF_STRINGS);
@ -156,7 +156,7 @@ static RBinInfo* info(RBin *bin)
char *str;
RBinInfo *ret = NULL;
if((ret = MALLOC_STRUCT (RBinInfo)) == NULL)
if((ret = R_NEW (RBinInfo)) == NULL)
return NULL;
memset(ret, '\0', sizeof (RBinInfo));
strncpy (ret->file, bin->file, R_BIN_SIZEOF_STRINGS);

View File

@ -37,7 +37,7 @@ static RList* entries(RBin *bin)
ret->free = free;
if (!(entry = PE_(r_bin_pe_get_entrypoint) (bin->bin_obj)))
return ret;
if ((ptr = MALLOC_STRUCT (RBinEntry))) {
if ((ptr = R_NEW (RBinEntry))) {
ptr->offset = entry->offset;
ptr->rva = entry->rva;
r_list_append (ret, ptr);
@ -59,7 +59,7 @@ static RList* sections(RBin *bin)
if (!(sections = PE_(r_bin_pe_get_sections)(bin->bin_obj)))
return ret;
for (i = 0; !sections[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinSection)))
if (!(ptr = R_NEW (RBinSection)))
break;
strncpy (ptr->name, (char*)sections[i].name, R_BIN_SIZEOF_STRINGS);
ptr->size = sections[i].size;
@ -94,7 +94,7 @@ static RList* symbols(RBin *bin)
if (!(symbols = PE_(r_bin_pe_get_exports)(bin->bin_obj)))
return ret;
for (i = 0; !symbols[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinSymbol)))
if (!(ptr = R_NEW (RBinSymbol)))
break;
strncpy (ptr->name, (char*)symbols[i].name, R_BIN_SIZEOF_STRINGS);
strncpy (ptr->forwarder, (char*)symbols[i].forwarder, R_BIN_SIZEOF_STRINGS);
@ -123,7 +123,7 @@ static RList* imports(RBin *bin)
if (!(imports = PE_(r_bin_pe_get_imports)(bin->bin_obj)))
return ret;
for (i = 0; !imports[i].last; i++) {
if (!(ptr = MALLOC_STRUCT (RBinImport)))
if (!(ptr = R_NEW (RBinImport)))
break;
strncpy (ptr->name, (char*)imports[i].name, R_BIN_SIZEOF_STRINGS);
strncpy (ptr->bind, "NONE", R_BIN_SIZEOF_STRINGS);
@ -163,7 +163,7 @@ static RBinInfo* info(RBin *bin)
char *str;
RBinInfo *ret = NULL;
if((ret = MALLOC_STRUCT (RBinInfo)) == NULL)
if((ret = R_NEW (RBinInfo)) == NULL)
return NULL;
memset(ret, '\0', sizeof (RBinInfo));
strncpy (ret->file, bin->file, R_BIN_SIZEOF_STRINGS);

View File

@ -26,7 +26,7 @@ R_API RBreakpoint *r_bp_init(RBreakpoint *bp) {
}
R_API RBreakpoint *r_bp_new() {
return r_bp_init (MALLOC_STRUCT (RBreakpoint));
return r_bp_init (R_NEW (RBreakpoint));
}
R_API RBreakpoint *r_bp_free(RBreakpoint *bp) {
@ -91,7 +91,7 @@ static RBreakpointItem *r_bp_add(RBreakpoint *bp, const ut8 *obytes, ut64 addr,
eprintf ("Breakpoint already set at this address.\n");
return NULL;
}
b = MALLOC_STRUCT (struct r_bp_item_t);
b = R_NEW (struct r_bp_item_t);
b->pids[0] = 0; /* for any pid */
b->addr = addr;
b->size = size;

View File

@ -16,7 +16,7 @@ R_API RCommand *r_cmd_init(struct r_cmd_t *cmd) {
}
R_API RCommand *r_cmd_new () {
return r_cmd_init (MALLOC_STRUCT (RCommand));
return r_cmd_init (R_NEW (RCommand));
}
R_API int r_cmd_set_data(struct r_cmd_t *cmd, void *data) {
@ -42,7 +42,7 @@ R_API int r_cmd_add(RCommand *c, const char *cmd, const char *desc, r_cmd_callba
item = c->cmds[idx];
if (item == NULL) {
item = MALLOC_STRUCT (RCommandItem);
item = R_NEW (RCommandItem);
c->cmds[idx] = item;
}
strncpy (item->cmd, cmd, sizeof (item->cmd));

View File

@ -30,7 +30,7 @@ struct r_cons_t {
struct r_cons_frame_t *r_cons_frame_new(int x, int y, int w, int h)
{
struct r_cons_frame_t *f = MALLOC_STRUCT(struct r_cons_frame_t);
struct r_cons_frame_t *f = R_NEW(struct r_cons_frame_t);
f->text = r_cons_buffer_new(w, h);
f->draw = r_cons_buffer_new(w, h);
f->w = w;
@ -75,7 +75,7 @@ void r_cons_buffer_line(struct r_cons_buffer_t *buf, int x0, int y0, int x1, int
struct r_cons_buffer *r_cons_buffer_new(int w, int h)
{
struct r_cons_buffer_t *buf = MALLOC_STRUCT(struct r_cons_buffer_t);
struct r_cons_buffer_t *buf = R_NEW(struct r_cons_buffer_t);
if (w<1) w=1;
if (h<1) h=1;
buf->rw = buf->w = w;
@ -86,7 +86,7 @@ struct r_cons_buffer *r_cons_buffer_new(int w, int h)
int r_cons_buffer_set_size(struct r_cons_buffer *buf, int w, int h)
{
struct r_cons_buffer_t *buf = MALLOC_STRUCT(struct r_cons_buffer_t);
struct r_cons_buffer_t *buf = R_NEW(struct r_cons_buffer_t);
if (w<1) w=1;
if (h<1) h=1;
if (w>buf->rw) {

View File

@ -51,7 +51,7 @@ static void r_core_anal_graph_nodes(struct r_core_t *core, RList *pbb, ut64 addr
r_list_foreach (core->anal.bbs, iter, bbi) {
if (addr == 0 || (addr >= bbi->addr && addr < bbi->addr+bbi->size)) {
if (pbb) { /* Copy BB and append to the list of printed bbs */
bbc = MALLOC_STRUCT (RAnalysisBB);
bbc = R_NEW (RAnalysisBB);
memcpy (bbc, bbi, sizeof (RAnalysisBB));
r_list_append (pbb, bbc);
}

View File

@ -54,7 +54,7 @@ static ut64 num_callback(void *userptr, const char *str, int *ok) {
}
R_API struct r_core_t *r_core_new() {
struct r_core_t *c = MALLOC_STRUCT (struct r_core_t);
struct r_core_t *c = R_NEW (struct r_core_t);
r_core_init (c);
return c;
}

View File

@ -18,7 +18,7 @@ R_API struct r_core_file_t *r_core_file_open(struct r_core_t *r, const char *fil
if (fd == -1)
return NULL;
fh = MALLOC_STRUCT (RCoreFile);
fh = R_NEW (RCoreFile);
fh->fd = fd;
fh->uri = strdup (file);
fh->filename = fh->uri;

View File

@ -40,13 +40,13 @@ R_API int r_crypto_del(struct r_crypto_t *cry, struct r_crypto_handle_t *h)
R_API struct r_crypto_t *r_crypto_new()
{
struct r_crypto_t *cry = MALLOC_STRUCT(struct r_crypto_t);
struct r_crypto_t *cry = R_NEW(struct r_crypto_t);
return r_crypto_init(cry, R_TRUE);
}
R_API struct r_crypto_t *r_crypto_as_new(struct r_crypto_t *cry)
{
struct r_crypto_t *c = MALLOC_STRUCT(struct r_crypto_t);
struct r_crypto_t *c = R_NEW(struct r_crypto_t);
if (c != NULL) {
r_crypto_init(c, R_FALSE); // soft init
memcpy(&c->handlers, &cry->handlers, sizeof(cry->handlers));

View File

@ -15,7 +15,7 @@ struct r_db_table_t *r_db_table_new(const char *name, const char *fmt, const cha
{
int i;
int offset = 0;
struct r_db_table_t *table = MALLOC_STRUCT(struct r_db_table_t);
struct r_db_table_t *table = R_NEW(struct r_db_table_t);
table->args = strdup(fields);
table->nelems = r_str_word_set0(table->args);
if (table->nelems != strlen(fmt)) {

View File

@ -40,9 +40,7 @@
#define BITS2BYTES(x) ((x/8)+((x%8)?1:0))
#define ZERO_FILL(x) memset (x, 0, sizeof (x))
#define MALLOC_STRUCTS(x,y) (x*)malloc(sizeof(x)*y)
#define MALLOC_STRUCT(x) (x*)malloc(sizeof(x))
// TODO: deprecate MALLOC_STRUCT... RNEW is cooler
#define R_NEWS(x,y) (x*)malloc(sizeof(x)*y)
#define R_NEW(x) (x*)malloc(sizeof(x))
#define IS_PRINTABLE(x) (x>=' '&&x<='~')
#define IS_WHITESPACE(x) (x==' '||x=='\t')
@ -104,7 +102,7 @@
#if 0
#define R_DEFINE_OBJECT(type) \
R_API struct type##_t* type##_new() { \
return type##_init(MALLOC_STRUCT(struct type##_t)); \
return type##_init(R_NEW(struct type##_t)); \
} \
R_API struct type##_t* type##_free(struct type##_t *foo) { \
return (type##_deinit(foo), free(foo), NULL); \

View File

@ -45,7 +45,7 @@ R_API int r_io_cache_invalidate(struct r_io_t *io, ut64 from, ut64 to)
R_API int r_io_cache_write(struct r_io_t *io, ut64 addr, const ut8 *buf, int len)
{
struct r_io_cache_t *ch = MALLOC_STRUCT(struct r_io_cache_t);
struct r_io_cache_t *ch = R_NEW(struct r_io_cache_t);
ch->from = addr;
ch->to = addr + len;
ch->size = len;

View File

@ -15,7 +15,7 @@ R_API int r_io_handle_add(struct r_io_t *io, struct r_io_handle_t *plugin) {
struct r_io_list_t *li;
if (plugin == NULL)
return R_FALSE;
li = MALLOC_STRUCT(struct r_io_list_t);
li = R_NEW(struct r_io_list_t);
if (li == NULL)
return R_FALSE;
li->plugin = plugin;

View File

@ -22,12 +22,12 @@ R_API struct r_io_t *r_io_init(struct r_io_t *io) {
}
R_API struct r_io_t *r_io_new() {
return r_io_init (MALLOC_STRUCT (struct r_io_t));
return r_io_init (R_NEW (struct r_io_t));
}
R_API RBuffer *r_io_read_buf(struct r_io_t *io, ut64 addr, int len)
{
RBuffer *b = MALLOC_STRUCT(RBuffer);
RBuffer *b = R_NEW(RBuffer);
b->buf = malloc(len);
len = r_io_read_at(io, addr, b->buf, len);
if (len<0) len = 0;

View File

@ -39,7 +39,7 @@ R_API int r_io_map_del(struct r_io_t *io, int fd)
R_API int r_io_map_add(struct r_io_t *io, int fd, int flags, ut64 delta, ut64 offset, ut64 size)
{
struct r_io_map_t *im = MALLOC_STRUCT(struct r_io_map_t);
struct r_io_map_t *im = R_NEW(struct r_io_map_t);
if (im == NULL)
return R_FALSE;
list_add_tail(&(im->list), &(io->maps));

View File

@ -95,7 +95,7 @@ R_API void r_io_wundo_new(struct r_io_t *io, ut64 off, const ut8 *data, int len)
return;
/* undo write changes */
uw = MALLOC_STRUCT(struct r_io_undo_w_t);
uw = R_NEW(struct r_io_undo_w_t);
uw->set = R_TRUE;
uw->off = off;
uw->len = len;

View File

@ -15,7 +15,7 @@ R_API struct r_lang_t *r_lang_init(struct r_lang_t *lang)
R_API struct r_lang_t *r_lang_new()
{
struct r_lang_t *lang = MALLOC_STRUCT(struct r_lang_t);
struct r_lang_t *lang = R_NEW(struct r_lang_t);
return r_lang_init(lang);
}
@ -50,7 +50,7 @@ R_API int r_lang_define(struct r_lang_t *lang, const char *type, const char *nam
}
}
if (!ret) {
def = MALLOC_STRUCT(struct r_lang_def_t);
def = R_NEW(struct r_lang_def_t);
if (def != NULL) {
def->type = strdup(type);
def->name = strdup(name);

View File

@ -76,7 +76,7 @@ R_API struct r_lib_t *r_lib_init(struct r_lib_t *lib, const char *symname)
R_API struct r_lib_t *r_lib_new(const char *symname)
{
struct r_lib_t *lib = MALLOC_STRUCT(struct r_lib_t);
struct r_lib_t *lib = R_NEW(struct r_lib_t);
return r_lib_init(lib, symname);
}
@ -203,7 +203,7 @@ R_API int r_lib_open(struct r_lib_t *lib, const char *file)
}
}
p = MALLOC_STRUCT(struct r_lib_plugin_t);
p = R_NEW(struct r_lib_plugin_t);
p->type = stru->type;
p->data = stru->data;
p->file = strdup(file);
@ -265,7 +265,7 @@ R_API int r_lib_add_handler(struct r_lib_t *lib,
}
}
if (handler == NULL) {
handler = MALLOC_STRUCT(struct r_lib_handler_t);
handler = R_NEW(struct r_lib_handler_t);
if (handler == NULL)
return R_FALSE;
handler->type = type;

View File

@ -8,7 +8,7 @@ R_API int r_meta_init(struct r_meta_t *m) {
}
R_API struct r_meta_t *r_meta_new() {
struct r_meta_t *m = MALLOC_STRUCT(struct r_meta_t);
struct r_meta_t *m = R_NEW(struct r_meta_t);
r_meta_init(m);
return m;
}
@ -164,7 +164,7 @@ int r_meta_add(struct r_meta_t *m, int type, ut64 from, ut64 size, const char *s
case R_META_FOLDER:
case R_META_XREF_CODE:
case R_META_XREF_DATA:
mi = MALLOC_STRUCT(struct r_meta_item_t);
mi = R_NEW(struct r_meta_item_t);
mi->type = type;
mi->from = from;
mi->size = size;

View File

@ -17,7 +17,7 @@ static struct r_parse_handle_t *parse_static_plugins[] =
R_API struct r_parse_t *r_parse_new()
{
struct r_parse_t *p = MALLOC_STRUCT(struct r_parse_t);
struct r_parse_t *p = R_NEW(struct r_parse_t);
return r_parse_init(p);
}

View File

@ -29,7 +29,7 @@ R_API int r_print_init(struct r_print_t *p)
struct r_print_t *r_print_new()
{
struct r_print_t *p = MALLOC_STRUCT(struct r_print_t);
struct r_print_t *p = R_NEW(struct r_print_t);
r_print_init(p);
return p;
}

View File

@ -269,7 +269,7 @@ static const char *str_get_arg(const char *buf)
//tokenizer* binparse_new(int kws)
R_API struct r_search_binparse_t *binparse_new(int kws)
{
struct r_search_binparse_t *tll = MALLOC_STRUCT(struct r_search_binparse_t);
struct r_search_binparse_t *tll = R_NEW(struct r_search_binparse_t);
if (tll == NULL)
return NULL;
tll->tls = (tokenlist**)malloc(sizeof (tokenlist*) * kws);

View File

@ -125,7 +125,7 @@ int main(int argc, char **argv)
int c;
while ((c = getopt(argc, argv, "b:m:s:x:Xzf:t:rnhV")) != -1) {
struct str_t *kw = MALLOC_STRUCT(struct str_t);
struct str_t *kw = R_NEW(struct str_t);
INIT_LIST_HEAD(&(kw->list));
switch(c) {

View File

@ -11,7 +11,7 @@
R_API struct r_socket_proc_t *r_socket_proc_open(char *const argv[])
{
#if __UNIX__
struct r_socket_proc_t *sp = MALLOC_STRUCT(struct r_socket_proc_t);
struct r_socket_proc_t *sp = R_NEW(struct r_socket_proc_t);
#if __APPLE__
const int flags = 0; //O_NONBLOCK|O_CLOEXEC;
#else

View File

@ -14,7 +14,7 @@ R_API void r_th_pool_init(struct r_th_pool_t *thp, int threads, int size)
R_API struct r_th_pool_t *r_th_pool_new(int threads, int size)
{
struct r_th_pool_t *thp = MALLOC_STRUCT(struct r_th_pool_t);
struct r_th_pool_t *thp = R_NEW(struct r_th_pool_t);
r_th_pool_init(thp, threads, size);
return thp;
}

View File

@ -19,7 +19,7 @@ R_API int r_th_lock_init(struct r_th_lock_t *thl)
R_API struct r_th_lock_t *r_th_lock_new()
{
struct r_th_lock_t *thl = MALLOC_STRUCT(struct r_th_lock_t);
struct r_th_lock_t *thl = R_NEW(struct r_th_lock_t);
if (!r_th_lock_init(thl))
R_FREE(thl);
return thl;

View File

@ -55,7 +55,7 @@ R_API int r_th_push_task(struct r_th_t *th, void *user)
R_API struct r_th_t *r_th_new(R_TH_FUNCTION(fun), void *user, int delay)
{
struct r_th_t *th = MALLOC_STRUCT(struct r_th_t);
struct r_th_t *th = R_NEW(struct r_th_t);
r_th_init(th, fun, user, delay);
return th;
}

View File

@ -19,7 +19,7 @@ int r_trace_init(struct r_trace_t *t)
struct r_trace_t *r_trace_new()
{
struct r_trace_t *tr = MALLOC_STRUCT(struct r_trace_t);
struct r_trace_t *tr = R_NEW(struct r_trace_t);
r_trace_init(tr);
return tr;
}
@ -147,7 +147,7 @@ int r_trace_add(struct r_trace_t *tr, ut64 addr, int opsize)
}
}
t = MALLOC_STRUCT(struct r_trace_item_t);
t = R_NEW(struct r_trace_item_t);
if (t == NULL) {
printf("Cannot alloc\n");
return -1;

View File

@ -9,7 +9,7 @@ R_API void r_cache_init(struct r_cache_t *c)
R_API struct r_cache_t *r_cache_new()
{
struct r_cache_t *a = MALLOC_STRUCT(struct r_cache_t);
struct r_cache_t *a = R_NEW(struct r_cache_t);
r_cache_init(a);
return a;
}
@ -32,7 +32,7 @@ R_API char *r_cache_get(struct r_cache_t *c, ut64 addr)
R_API int r_cache_set(struct r_cache_t *c, ut64 addr, char *str)
{
struct r_cache_item_t *a = MALLOC_STRUCT(struct r_cache_item_t);
struct r_cache_item_t *a = R_NEW(struct r_cache_item_t);
a->addr = addr;
a->str = strdup(str);
list_add_tail(&(a->list), &(c->items));

View File

@ -52,7 +52,7 @@ R_API void r_list_delete (RList *list, RListIter *iter) {
}
R_API RList *r_list_new() {
RList *list = MALLOC_STRUCT (RList);
RList *list = R_NEW (RList);
r_list_init (list);
return list;
}
@ -73,7 +73,7 @@ R_API void r_list_free (RList *list) {
}
R_API RListIter *r_list_item_new (void *data) {
RListIter *new = MALLOC_STRUCT (RListIter);
RListIter *new = R_NEW (RListIter);
new->data = data;
return new;
}
@ -95,7 +95,7 @@ R_API RListIter *r_list_append(RList *list, void *data) {
}
R_API RListIter *r_list_prepend(RList *list, void *data) {
RListIter *new = MALLOC_STRUCT (RListIter);
RListIter *new = R_NEW (RListIter);
if (list->head)
list->head->p = new;
new->data = data;

View File

@ -40,7 +40,7 @@ R_API struct r_mem_pool_t* r_mem_pool_init(struct r_mem_pool_t *pool, int nsize,
R_API struct r_mem_pool_t *r_mem_pool_new(int nodesize, int poolsize, int poolcount)
{
return r_mem_pool_init (MALLOC_STRUCT (struct r_mem_pool_t),
return r_mem_pool_init (R_NEW (struct r_mem_pool_t),
nodesize, poolsize, poolcount);
}

View File

@ -4,7 +4,7 @@
R_API int r_vm_mmu_cache_write(struct r_vm_t *vm, ut64 addr, ut8 *buf, int len)
{
struct r_vm_change_t *ch = MALLOC_STRUCT(struct r_vm_change_t);
struct r_vm_change_t *ch = R_NEW(struct r_vm_change_t);
ch->from = addr;
ch->to = addr + len;
ch->data = (ut8*)malloc(len);

View File

@ -5,7 +5,7 @@
int r_vm_op_add(struct r_vm_t *vm, const char *op, const char *str)
{
struct r_vm_op_t *o;
o = MALLOC_STRUCT(struct r_vm_op_t);
o = R_NEW(struct r_vm_op_t);
if (o == NULL)
return -1;
strncpy(o->opcode, op, sizeof(o->opcode));