diff options
Diffstat (limited to 'src/glibext')
-rw-r--r-- | src/glibext/delayed-int.h | 4 | ||||
-rw-r--r-- | src/glibext/delayed.c | 53 | ||||
-rw-r--r-- | src/glibext/gbinportion.h | 6 |
3 files changed, 25 insertions, 38 deletions
diff --git a/src/glibext/delayed-int.h b/src/glibext/delayed-int.h index d56f2e9..60363e1 100644 --- a/src/glibext/delayed-int.h +++ b/src/glibext/delayed-int.h @@ -46,8 +46,8 @@ struct _GDelayedWork run_task_fc run; /* Traitement externalisé */ bool completed; /* Fin de la tâche ? */ - GMutex *mutex; /* Accès à la variable */ - GCond *cond; /* Attente de changement */ + GMutex mutex; /* Accès à la variable */ + GCond cond; /* Attente de changement */ }; diff --git a/src/glibext/delayed.c b/src/glibext/delayed.c index ae943d7..1a8c5bb 100644 --- a/src/glibext/delayed.c +++ b/src/glibext/delayed.c @@ -72,8 +72,8 @@ typedef struct _GTypedQueue GtkExtStatusBar *statusbar; /* Barre de statut principale */ GDelayedWork *works; /* Tâches à mener à bien */ - GMutex *mutex; /* Verrou pour l'accès */ - GCond *cond; /* Réveil pour un traitement */ + GMutex mutex; /* Verrou pour l'accès */ + GCond cond; /* Réveil pour un traitement */ GThread *thread; /* Procédure de traitement */ @@ -200,8 +200,8 @@ static void g_delayed_work_class_init(GDelayedWorkClass *klass) static void g_delayed_work_init(GDelayedWork *work) { work->completed = false; - work->mutex = g_mutex_new(); - work->cond = g_cond_new(); + g_mutex_init(&work->mutex); + g_cond_init(&work->cond); } @@ -220,8 +220,8 @@ static void g_delayed_work_init(GDelayedWork *work) static void g_delayed_work_dispose(GDelayedWork *work) { - g_mutex_free(work->mutex); - g_cond_free(work->cond); + g_mutex_clear(&work->mutex); + g_cond_clear(&work->cond); G_OBJECT_CLASS(g_delayed_work_parent_class)->dispose(G_OBJECT(work)); @@ -264,12 +264,12 @@ static void g_delayed_work_process(GDelayedWork *work, GtkExtStatusBar *statusba { work->run(work, statusbar); - g_mutex_lock(work->mutex); + g_mutex_lock(&work->mutex); work->completed = true; - g_cond_signal(work->cond); - g_mutex_unlock(work->mutex); + g_cond_signal(&work->cond); + g_mutex_unlock(&work->mutex); g_signal_emit_by_name(work, "work-completed"); @@ -290,12 +290,12 @@ static void g_delayed_work_process(GDelayedWork *work, GtkExtStatusBar *statusba void g_delayed_work_wait_for_completion(GDelayedWork *work) { - g_mutex_lock(work->mutex); + g_mutex_lock(&work->mutex); while (!work->completed) - g_cond_wait(work->cond, work->mutex); + g_cond_wait(&work->cond, &work->mutex); - g_mutex_unlock(work->mutex); + g_mutex_unlock(&work->mutex); } @@ -348,17 +348,10 @@ static void g_typed_queue_class_init(GTypedQueueClass *klass) static void g_typed_queue_init(GTypedQueue *queue) { - GError *error; /* Bilan de création de thread */ + g_mutex_init(&queue->mutex); + g_cond_init(&queue->cond); - queue->mutex = g_mutex_new(); - if (queue->mutex == NULL) - goto gtqi_error; - - queue->cond = g_cond_new(); - if (queue->cond == NULL) - goto gtqi_error; - - queue->thread = g_thread_create((GThreadFunc)g_typed_queue_process, queue, FALSE, &error); + queue->thread = g_thread_new("chrysalide_queue", (GThreadFunc)g_typed_queue_process, queue); if (!queue->thread) goto gtqi_error; @@ -383,8 +376,8 @@ static void g_typed_queue_init(GTypedQueue *queue) static void g_typed_queue_dispose(GTypedQueue *queue) { - g_mutex_free(queue->mutex); - g_cond_free(queue->cond); + g_mutex_clear(&queue->mutex); + g_cond_clear(&queue->cond); G_OBJECT_CLASS(g_typed_queue_parent_class)->dispose(G_OBJECT(queue)); @@ -454,13 +447,13 @@ static GTypedQueue *g_typed_queue_new(GType type, GtkExtStatusBar *statusbar) static void g_typed_queue_schedule(GTypedQueue *queue, GDelayedWork *work) { - g_mutex_lock(queue->mutex); + g_mutex_lock(&queue->mutex); delayed_work_list_add_tail(work, &queue->works); - g_cond_signal(queue->cond); + g_cond_signal(&queue->cond); - g_mutex_unlock(queue->mutex); + g_mutex_unlock(&queue->mutex); } @@ -483,15 +476,15 @@ static void *g_typed_queue_process(GTypedQueue *queue) while (1) { - g_mutex_lock(queue->mutex); + g_mutex_lock(&queue->mutex); if (dl_list_empty(queue->works)) - g_cond_wait(queue->cond, queue->mutex); + g_cond_wait(&queue->cond, &queue->mutex); work = queue->works; delayed_work_list_del(work, &queue->works); - g_mutex_unlock(queue->mutex); + g_mutex_unlock(&queue->mutex); g_delayed_work_process(work, queue->statusbar); diff --git a/src/glibext/gbinportion.h b/src/glibext/gbinportion.h index 826d65f..ca232d4 100644 --- a/src/glibext/gbinportion.h +++ b/src/glibext/gbinportion.h @@ -48,7 +48,6 @@ typedef fnv64_t bp_color_t; #define BP_INHERIT_COLOR 1 - #define BPC_RAW "raw" #define BPC_CODE "code" #define BPC_DATA "data" @@ -56,9 +55,6 @@ typedef fnv64_t bp_color_t; #define BPC_DISASS_ERROR "disassembly-error" - - - /* Enregistre une couleur pour le dessin de portions. */ bool register_binary_portion_color(const char *, uint8_t, uint8_t, uint8_t, uint8_t); @@ -73,8 +69,6 @@ void exit_binary_portion_colors(void); - - #define G_TYPE_BIN_PORTION (g_binary_portion_get_type()) #define G_BIN_PORTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_BIN_PORTION, GBinPortion)) #define G_IS_BIN_PORTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_BIN_PORTION)) |