From 34f0ead7c89b716c6a9f59f8dea6a9450e37e82a Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 3 Oct 2016 00:38:13 +0200 Subject: Given more flexibility to qinsert() for the inserted item. --- ChangeLog | 8 ++++++++ src/common/sort.c | 4 ++-- src/format/format.c | 7 +++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 332e6fa..9024665 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +16-10-03 Cyrille Bagard + + * src/common/sort.c: + Give more flexibility to qinsert() for the inserted item. + + * src/format/format.c: + Update code. + 16-09-29 Cyrille Bagard * src/format/mangling/dex/type_gram.y: diff --git a/src/common/sort.c b/src/common/sort.c index df1df82..ee6cf2e 100644 --- a/src/common/sort.c +++ b/src/common/sort.c @@ -123,7 +123,7 @@ void *qinsert(void *base, size_t *nmemb, size_t size, __compar_fn_t compar, void void *result; /* Tableau trié à retourner */ size_t index; /* Indice du point d'insertion */ - bsearch_index(&new, base, *nmemb, size, compar, &index); + bsearch_index(new, base, *nmemb, size, compar, &index); result = realloc(base, (*nmemb + 1) * size); @@ -132,7 +132,7 @@ void *qinsert(void *base, size_t *nmemb, size_t size, __compar_fn_t compar, void (*nmemb)++; - memcpy((char *)result + index * size, &new, size); + memcpy((char *)result + index * size, new, size); return result; diff --git a/src/format/format.c b/src/format/format.c index 5e5755c..be3627e 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -294,6 +294,7 @@ void g_binary_format_add_symbol(GBinFormat *format, GBinSymbol *symbol) const mrange_t *range; /* Couverture du symbole */ const vmpa2t *addr; /* Emplacement du symbole */ #endif + GBinRoutine *routine; /* Nouvelle routine à insérer */ /** * Lorsque les fonctions de recherche type g_binary_format_find_symbol_at() @@ -316,16 +317,18 @@ void g_binary_format_add_symbol(GBinFormat *format, GBinSymbol *symbol) g_rw_lock_writer_lock(&format->syms_lock); format->symbols = qinsert(format->symbols, &format->symbols_count, - sizeof(GBinSymbol *), (__compar_fn_t)g_binary_symbol_cmp, symbol); + sizeof(GBinSymbol *), (__compar_fn_t)g_binary_symbol_cmp, &symbol); switch (g_binary_symbol_get_target_type(symbol)) { case STP_ROUTINE: case STP_ENTRY_POINT: + routine = g_binary_symbol_get_routine(symbol); + format->routines = qinsert(format->routines, &format->routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_compare, - g_binary_symbol_get_routine(symbol)); + &routine); break; default: -- cgit v0.11.2-87-g4458