update meta info when the key exists

This commit is contained in:
Álvaro Felipe Melchor 2016-02-11 12:26:18 +01:00 committed by pancake
parent 27d60454a4
commit fdfd8801c9

View File

@ -228,15 +228,15 @@ R_API int r_meta_add(RAnal *a, int type, ut64 from, ut64 to, const char *str) {
// to inconsistent DB, and pretty bad performance. We should
// store this list in a different storage that doesnt have
// those limits and it's O(1) instead of O(n)
if (!exists) {
//ut64 count;
/* set type index */
snprintf (key, sizeof (key)-1, "meta.0x%"PFMT64x, from);
snprintf (val, sizeof (val)-1, "%c", type);
sdb_array_add (DB, key, val, 0);
/* set type index */
//count = meta_type_add (a, type, from);
snprintf (key, sizeof (key)-1, "meta.0x%"PFMT64x, from);
if (exists) {
char *value = sdb_get (DB, key, 0);
int idx = sdb_array_indexof (DB, key, value, 0);
sdb_array_delete (DB, key, idx, 0);
}
snprintf (val, sizeof (val)-1, "%c", type);
sdb_array_add (DB, key, val, 0);
return true;
}