summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-01-16 18:42:29 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-01-16 18:42:29 (GMT)
commiteb9b7fd76451db5c9f07a800c0394480e4b88c9c (patch)
tree0ed8261cffd4a40f4f7924f4dc12cc37c00bf554 /src/format
parent23b9c6e68bbe5f0531f9a9408c2deb9f897701dc (diff)
Improved the removal of format symbols.
Diffstat (limited to 'src/format')
-rw-r--r--src/format/format.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/format/format.c b/src/format/format.c
index a188204..b975a7c 100644
--- a/src/format/format.c
+++ b/src/format/format.c
@@ -654,15 +654,18 @@ static void _g_binary_format_remove_symbol(GBinFormat *format, size_t index)
void g_binary_format_remove_symbol(GBinFormat *format, GBinSymbol *symbol)
{
- size_t i; /* Boucle de parcours */
+ bool found; /* Jeton de présence */
+ size_t index; /* Indice du point de retrait */
+
+ g_binary_format_lock_unlock_symbols_wr(format, true);
- // FIXME : dicho
+ found = bsearch_index(&symbol, format->symbols, format->sym_count,
+ sizeof(GBinSymbol *), (__compar_fn_t)g_binary_symbol_cmp, &index);
- for (i = 0; i < format->sym_count; i++)
- if (format->symbols[i] == symbol)
- break;
+ if (found)
+ _g_binary_format_remove_symbol(format, index);
- _g_binary_format_remove_symbol(format, i);
+ g_binary_format_lock_unlock_symbols_wr(format, false);
}