diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/dalvik/register.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/plugins/dalvik/register.c b/plugins/dalvik/register.c index 51abe2f..0833650 100644 --- a/plugins/dalvik/register.c +++ b/plugins/dalvik/register.c @@ -86,6 +86,7 @@ GDalvikRegister *_g_dalvik_register_new(uint16_t); /* Conservation des registres utilisés */ static GDalvikRegister **_dalvik_registers = NULL; static uint16_t _dreg_count = 0; +G_LOCK_DEFINE_STATIC(_dreg_mutex); /* Fournit le singleton associé à un registre Dalvik. */ @@ -362,6 +363,8 @@ static GDalvikRegister *get_dalvik_register(uint16_t index) GDalvikRegister *result; /* Structure à retourner */ uint16_t i; /* Boucle de parcours */ + G_LOCK(_dreg_mutex); + if (index >= _dreg_count) { _dalvik_registers = realloc(_dalvik_registers, (index + 1) * sizeof(GDalvikRegister *)); @@ -378,6 +381,8 @@ static GDalvikRegister *get_dalvik_register(uint16_t index) result = _dalvik_registers[index]; + G_UNLOCK(_dreg_mutex); + g_object_ref(G_OBJECT(result)); return result; @@ -401,6 +406,8 @@ void clean_dalvik_register_cache(void) { uint16_t i; /* Boucle de parcours */ + G_LOCK(_dreg_mutex); + for (i = 0; i < _dreg_count; i++) g_object_unref(G_OBJECT(_dalvik_registers[i])); @@ -410,4 +417,6 @@ void clean_dalvik_register_cache(void) _dalvik_registers = NULL; _dreg_count = 0; + G_UNLOCK(_dreg_mutex); + } |