From 3523578cf170d9e98e2c0c5b2f3b6f7de4318a03 Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Fri, 23 Jun 2023 15:47:02 +0900
Subject: Fix functionality broken by commit d619f66

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 kmtrace/demangle.cpp |  1 -
 kmtrace/kmtrace.cpp  | 18 +++++++++---------
 kmtrace/match.cpp    |  1 -
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/kmtrace/demangle.cpp b/kmtrace/demangle.cpp
index d552137c..800629c9 100644
--- a/kmtrace/demangle.cpp
+++ b/kmtrace/demangle.cpp
@@ -3,7 +3,6 @@
 #include <tqstringlist.h>
 #include <tqstrlist.h>
 #include <tqtextstream.h>
-#include <tqptrlist.h>
 #include <tqfile.h>
 #include <tqtl.h>
 #include <tqvaluelist.h>
diff --git a/kmtrace/kmtrace.cpp b/kmtrace/kmtrace.cpp
index 6e30b01c..477cae7d 100644
--- a/kmtrace/kmtrace.cpp
+++ b/kmtrace/kmtrace.cpp
@@ -1,12 +1,13 @@
 #include <tqintdict.h>
 #include <stdio.h>
+#include <list>
 #ifdef Q_OS_SOLARIS
 #include <strings.h> /* index(), rindex() */
 #endif
+
 #include <tqstringlist.h>
 #include <tqstrlist.h>
 #include <tqtextstream.h>
-#include <tqptrlist.h>
 #include <tqfile.h>
 #include <tqtl.h>
 #include <tqvaluelist.h>
@@ -54,7 +55,7 @@ struct Entry {
 TQIntDict<Entry> *entryDict = 0;
 TQIntDict<char> *symbolDict = 0;
 TQIntDict<char> *formatDict = 0;
-TQPtrList<Entry> *entryList = 0;
+std::list<Entry*> *entryList = 0;
 TQStrList *excludes = 0;
 
 const char * const unknown = "<unknown>";
@@ -155,14 +156,14 @@ void sortBlocks()
    {
       Entry *entry = it.current();
       totalBytesLeaked += entry->total_size;
-      entryList->append(entry);
+      entryList->push_back(entry);
       for(int i = 0; entry->backtrace[i]; i++)
       {
          if (!symbolDict->find(entry->backtrace[i]))
              symbolDict->insert(entry->backtrace[i], unknown);
       }
    }
-   entryList->sort();
+	 entryList->sort([](Entry *a, Entry *b) { return *a < *b; });
 }
 
 void collectDupes()
@@ -359,7 +360,7 @@ void dumpBlocks()
 {
    int filterBytes = 0;
    int filterCount = 0;
-   for(Entry *entry = entryList->first();entry; entry = entryList->next())
+   for (Entry *entry : *entryList)
    {
       for(int i = 0; entry->backtrace[i]; i++)
       {
@@ -375,7 +376,7 @@ void dumpBlocks()
       filterCount++;
    }
    printf("Leaked memory after filtering: %d bytes in %d blocks.\n", filterBytes, filterCount);
-   for(Entry *entry = entryList->first();entry; entry = entryList->next())
+   for (Entry *entry : *entryList)
    {
       if (!entry->total_size) continue;
       printf("[%d bytes in %d blocks, 1st. block is %d bytes at 0x%08x] ", entry->total_size, entry->count, entry->size, entry->base);
@@ -431,8 +432,7 @@ TreeList * treeList = 0;
 
 void buildTree ()
 {
-   for (Entry * entry = entryList->first ();
-	entry != NULL; entry = entryList->next ())
+   for (Entry *entry : *entryList)
    {
       if (!entry->total_size)
 	 continue;
@@ -622,7 +622,7 @@ int main(int argc, char *argv[])
   entryDict = new TQIntDict<Entry>(9973);
   symbolDict = new TQIntDict<char>(9973);
   formatDict = new TQIntDict<char>(9973);
-  entryList = new TQPtrList<Entry>;
+  entryList = new std::list<Entry*>;
 
   fprintf(stderr, "Running\n");
   TQCString line;
diff --git a/kmtrace/match.cpp b/kmtrace/match.cpp
index eebcaf0a..ee00ca43 100644
--- a/kmtrace/match.cpp
+++ b/kmtrace/match.cpp
@@ -3,7 +3,6 @@
 #include <tqstringlist.h>
 #include <tqstrlist.h>
 #include <tqtextstream.h>
-#include <tqptrlist.h>
 #include <tqfile.h>
 #include <tqtl.h>
 #include <tqvaluelist.h>
-- 
cgit v1.2.3

