diff --git a/libr/include/r_types.h b/libr/include/r_types.h index 11d85cf2d7..1d5171c330 100644 --- a/libr/include/r_types.h +++ b/libr/include/r_types.h @@ -176,7 +176,7 @@ typedef void (*PrintfCallback)(const char *str, ...); #define BITS2BYTES(x) (((x)/8)+(((x)%8)?1:0)) #define ZERO_FILL(x) memset (&x, 0, sizeof (x)) -#define R_NEWS0(x,y) (x*)calloc(sizeof(x),y) +#define R_NEWS0(x,y) (x*)calloc(y,sizeof(x)) #define R_NEWS(x,y) (x*)malloc(sizeof(x)*y) #define R_NEW0(x) (x*)calloc(1,sizeof(x)) #define R_NEW(x) (x*)malloc(sizeof(x)) diff --git a/libr/include/r_util.h b/libr/include/r_util.h index 41c1b68546..f593c80fd1 100644 --- a/libr/include/r_util.h +++ b/libr/include/r_util.h @@ -297,6 +297,7 @@ R_API void r_graph_add_edge (RGraph *g, RGraphNode *from, RGraphNode *to); R_API RList *r_graph_get_neighbours (RGraph *g, RGraphNode *n); R_API int r_graph_adjacent (RGraph *g, RGraphNode *from, RGraphNode *to); +R_API int r_file_is_abspath(const char *file); R_API boolt r_file_truncate (const char *filename, ut64 newsize); R_API ut64 r_file_size(const char *str); R_API char *r_file_root(const char *root, const char *path); diff --git a/libr/util/graph.c b/libr/util/graph.c index 00b4d5a83c..7b8699e4b7 100644 --- a/libr/util/graph.c +++ b/libr/util/graph.c @@ -27,8 +27,8 @@ static void r_graph_node_free (RGraphNode *n) { R_API RGraph *r_graph_new () { RGraph *t = R_NEW0 (RGraph); t->capacity = INITIAL_CAPACITY; - t->nodes = calloc (t->capacity, sizeof(RGraphNode *)); - t->adjacency = calloc (t->capacity, sizeof(RList *)); + t->nodes = R_NEWS0 (RGraphNode *, t->capacity); + t->adjacency = R_NEWS0 (RList *, t->capacity); t->n_nodes = 0; t->last_index = -1; return t; @@ -64,8 +64,8 @@ R_API void r_graph_reset (RGraph *t) { } free (t->nodes); t->capacity = INITIAL_CAPACITY; - t->nodes = calloc (t->capacity, sizeof(RGraphNode *)); - t->adjacency = calloc (t->capacity, sizeof(RList *)); + t->nodes = R_NEWS0 (RGraphNode *, t->capacity); + t->adjacency = R_NEWS0 (RList *, t->capacity); t->n_nodes = 0; } diff --git a/libr/util/queue.c b/libr/util/queue.c index 07ec348f5b..cdfca1a4a0 100644 --- a/libr/util/queue.c +++ b/libr/util/queue.c @@ -4,7 +4,7 @@ R_API RQueue *r_queue_new (int n) { RQueue *q = R_NEW0 (RQueue); - q->elems = calloc (n, sizeof(void *)); + q->elems = R_NEWS0 (void *, n); if (!q->elems) return NULL; @@ -29,7 +29,7 @@ static int increase_capacity (RQueue *q) { void **newelems; int i, tmp_front; - newelems = calloc (new_capacity, sizeof(void *)); + newelems = R_NEWS0(void *, new_capacity); if (!newelems) return R_FALSE; diff --git a/libr/util/stack.c b/libr/util/stack.c index 73d80e526e..1cd7492773 100644 --- a/libr/util/stack.c +++ b/libr/util/stack.c @@ -4,7 +4,7 @@ R_API RStack *r_stack_new (unsigned int n) { RStack *s = R_NEW0 (RStack); - s->elems = calloc(n, sizeof(void *)); + s->elems = R_NEWS0 (void *, n); if (!s->elems) return NULL;