mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-20 20:55:32 +00:00
29166cc940
* Use '_' key in visual mode to enter in hud mode * Support mach0 files with multiple sections with same name * Fix parsing of commands with nested quotes * rename ?z to ?l * added new command ?y to get and set yank buffer contents to stdout * ?i stores the input into the yank buffer now * ?I accepts a file name as argument which is loaded as hud * ?k used as key=value temporal storage * Add calc.c .. plans are: - support proper parenthesis in math.c - support floating point arithmetics
64 lines
1.4 KiB
C
64 lines
1.4 KiB
C
/* radare - LGPL - Copyright 2010-2012 pancake <@nopcode.org> */
|
|
|
|
// XXX: forced free?? We need RFlist struct here
|
|
#include <r_types.h>
|
|
//#include <r_flist.h>
|
|
// NOTE: reimplemnetation of r_flist in C (if no R_API defined)
|
|
|
|
#if 1
|
|
#define r_flist_t void**
|
|
#define RFList void**
|
|
#define r_flist_rewind(it) for (; it!=*it; it--); it++
|
|
#define r_flist_next(it) *it!=0
|
|
#define r_flist_get(it) *(it++)
|
|
#define r_flist_iterator(x) x
|
|
#define r_flist_unref(x) x
|
|
#endif
|
|
|
|
R_API void **r_flist_new(int n) {
|
|
void **it;
|
|
if (!(it = (void **)malloc ((n+2) * sizeof (void*))))
|
|
return NULL;
|
|
*it = it;
|
|
memset (++it, 0, (n+1) * sizeof (void*));
|
|
return it;
|
|
}
|
|
|
|
// XXX. this is wrong :?
|
|
R_API void **r_flist_resize(void **it, int n) {
|
|
r_flist_rewind (it);
|
|
it--;
|
|
it = realloc (it, ((n+2) * sizeof (void*)));
|
|
*it = it;
|
|
return it+1;
|
|
}
|
|
|
|
R_API void **r_flist_prev(void **it) {
|
|
void **p = it--;
|
|
return (it==*it)?p:it;
|
|
}
|
|
|
|
R_API void r_flist_set(void **it, int idx, void *data) {
|
|
r_flist_rewind (it);
|
|
it[idx] = data;
|
|
}
|
|
|
|
R_API void r_flist_delete(void **it, int idx) {
|
|
r_flist_rewind (it);
|
|
free (it[idx]);
|
|
it[idx] = NULL;
|
|
for (it += idx; *it; it++) *it = *(it+1);
|
|
}
|
|
|
|
#define r_flist_foreach(it, pos) \
|
|
r_flist_rewind(it); \
|
|
while (r_flist_next (it) && (pos = r_flist_get (it)))
|
|
|
|
R_API void r_flist_free(void **it) {
|
|
void *pos;
|
|
r_flist_foreach (it, pos)
|
|
free (pos);
|
|
r_flist_rewind (it);
|
|
free (--it);
|
|
}
|