ithewei 6 tahun lalu
induk
melakukan
1db2b57cc3
3 mengubah file dengan 15 tambahan dan 13 penghapusan
  1. 1 1
      utils/hmain.cpp
  2. 8 5
      utils/iniparser.cpp
  3. 6 7
      utils/iniparser.h

+ 1 - 1
utils/hmain.cpp

@@ -311,7 +311,7 @@ void delete_pidfile() {
 pid_t getpid_from_pidfile() {
     FILE* fp = fopen(g_main_ctx.pidfile, "r");
     if (fp == NULL) {
-        hloge("fopen('%s') error: %d", g_main_ctx.pidfile, errno);
+        // hloge("fopen('%s') error: %d", g_main_ctx.pidfile, errno);
         return -1;
     }
     char pid[64];

+ 8 - 5
utils/iniparser.cpp

@@ -1,13 +1,16 @@
 #include "iniparser.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "hdef.h"
+#include "herr.h"
+#include "hstring.h"
+#include "hfile.h"
+#include "hbase.h"
 
 #include <sstream>
 
-#include "herr.h"
-#include "hfile.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 IniParser::IniParser() {
     _comment = DEFAULT_INI_COMMENT;

+ 6 - 7
utils/iniparser.h

@@ -1,12 +1,9 @@
 #ifndef HW_INI_PARSER_H_
 #define HW_INI_PARSER_H_
 
-#include "hdef.h"
-#include "hstring.h"
-#include "hbase.h"
-
 #include <list>
 #include <string>
+using std::string;
 
 #define DEFAULT_INI_COMMENT "#"
 #define DEFAULT_INI_DELIM   "="
@@ -36,8 +33,10 @@ class IniNode {
     std::list<IniNode*>    children;
 
     virtual ~IniNode() {
-        for (auto& item : children) {
-            SAFE_DELETE(item);
+        for (auto pNode : children) {
+            if (pNode) {
+                delete pNode;
+            }
         }
         children.clear();
     }
@@ -57,7 +56,7 @@ class IniNode {
     }
 
     IniNode* Get(const string& label, Type type = INI_NODE_TYPE_KEY_VALUE) {
-        for (auto& pNode : children) {
+        for (auto pNode : children) {
             if (pNode->type == type && pNode->label == label) {
                 return pNode;
             }