From 7d7f7da400e78cd562fd02ed668ea2b677b219be Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Mon, 18 Jun 2018 23:54:00 +0200
Subject: Extended any existing comment when documenting syscalls.

---
 plugins/lnxsyscalls/writer.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/plugins/lnxsyscalls/writer.c b/plugins/lnxsyscalls/writer.c
index 1263429..caa5501 100644
--- a/plugins/lnxsyscalls/writer.c
+++ b/plugins/lnxsyscalls/writer.c
@@ -197,25 +197,42 @@ void write_all_comments(comment_writer *writer, GPreloadInfo *preload)
     size_t i;                               /* Boucle de parcours #1       */
     comment_data *target;                   /* Commentaire à éditer        */
     GDbComment *comment;                    /* Commentaire final à intégrer*/
+    bool new;                               /* Nature du commentaire       */
     size_t k;                               /* Boucle de parcours #2       */
 
     for (i = 0; i < writer->count; i++)
     {
         target = &writer->comments[i];
 
-        comment = g_db_comment_new_inlined(&target->addr, BLF_HAS_CODE, false);
-        g_db_item_set_volatile(G_DB_ITEM(comment), true);
+        g_preload_info_lock_comments(preload);
+
+        comment = _g_preload_info_find_comment_at(preload, &target->addr);
+
+        new = (comment == NULL);
+
+        if (comment == NULL)
+        {
+            comment = g_db_comment_new_inlined(&target->addr, BLF_HAS_CODE, false);
+            g_db_item_set_volatile(G_DB_ITEM(comment), true);
+
+            g_object_ref(G_OBJECT(comment));
+
+            _g_preload_info_add_comment(preload, comment);
+
+        }
+
+        g_preload_info_unlock_comments(preload);
 
         for (k = 0; k < target->count; k++)
         {
-            if (k > 0)
+            if (k > 0 || !new)
                 g_db_comment_add_static_text(comment, " / ");
 
             g_db_comment_add_dynamic_text(comment, strdup(target->text[k]));
 
         }
 
-        g_preload_info_add_comment(preload, comment);
+        g_object_unref(G_OBJECT(comment));
 
     }
 
-- 
cgit v0.11.2-87-g4458