Type and null check fixes for RConfig

This commit is contained in:
pancake 2021-01-18 11:14:29 +01:00 committed by pancake
parent 773695d835
commit 3d2856bb81
5 changed files with 14 additions and 15 deletions

View File

@ -620,9 +620,9 @@ static int cmp(RConfigNode *a, RConfigNode *b) {
return strcmp (a->name, b->name);
}
R_API void r_config_lock(RConfig *cfg, int l) {
R_API void r_config_lock(RConfig *cfg, bool lock) {
r_list_sort (cfg->nodes, (RListComparator) cmp);
cfg->lock = l;
cfg->lock = lock;
}
R_API bool r_config_readonly(RConfig *cfg, const char *key) {
@ -647,7 +647,7 @@ R_API RConfig* r_config_new(void *user) {
}
cfg->user = user;
cfg->num = NULL;
cfg->lock = 0;
cfg->lock = false;
cfg->cb_printf = (void *) printf;
return cfg;
}

View File

@ -20,7 +20,7 @@ typedef bool (*RConfigCallback)(void *user, void *data);
typedef struct r_config_node_t {
char *name;
int flags;
ut32 flags;
char *value;
ut64 i_value;
ut64 *cb_ptr_q;
@ -35,12 +35,12 @@ typedef struct r_config_node_t {
R_API const char *r_config_node_type(RConfigNode *node);
typedef struct r_config_t {
int lock;
void *user;
RNum *num;
PrintfCallback cb_printf;
RList *nodes;
HtPP *ht;
bool lock;
} RConfig;
typedef struct r_config_hold_num_t {

View File

@ -57,20 +57,18 @@ typedef struct r_oflist_t {
#define r_list_foreach_prev_safe(list, it, tmp, pos) \
for (it = list->tail; it && (pos = it->data, tmp = it->p, 1); it = tmp)
#ifndef _R_LIST_C_
#define r_list_push(x, y) r_list_append (x, y)
#define r_list_push(x, y) r_list_append ((x), (y))
#define r_list_iterator(x) (x)? (x)->head: NULL
// #define r_list_empty(x) (!x || (!(x->head) && !(x->tail)))
#define r_list_empty(x) (!(x) || !(x)->length)
#define r_list_head(x) ((x)? (x)->head: NULL)
#define r_list_tail(x) ((x)? (x)->tail: NULL)
#define r_list_iter_get(x)\
x->data;\
x = x->n
#define r_list_iter_next(x) (x? 1: 0)
#define r_list_iter_get(x) (x)->data; (x)=(x)->n
#define r_list_iter_next(x) ((x)? 1: 0)
#define r_list_iter_cur(x) x->p
#define r_list_iter_free(x) x
#define r_list_iter_cur(x) (x)->p
#define r_list_iter_free(x) (x)
#endif
R_API RList *r_list_new(void);
R_API RList *r_list_newf(RListFree f);

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2018 - pancake */
/* radare - LGPL - Copyright 2009-2021 - pancake */
#ifndef R2_SYSCALL_H
#define R2_SYSCALL_H

View File

@ -64,8 +64,9 @@ R_API int r_list_length(const RList *list) {
/* remove all elements of a list */
R_API void r_list_purge(RList *list) {
r_return_if_fail (list);
if (!list) {
return;
}
RListIter *it = list->head;
while (it) {
RListIter *next = it->n;